groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff] Potential buffer overrun in src/roff/troff/input.cpp


From: Keith Marshall
Subject: [Groff] Potential buffer overrun in src/roff/troff/input.cpp
Date: Tue, 23 Sep 2014 20:12:39 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0

Folks,

While following up on:
http://thread.gmane.org/gmane.comp.printing.groff.general/12353/focus=12368

I've identified a potential buffer overrun in the above file; (it *will*
overrun, if function ps_get_line() reads a maximum length line of 255
input characters -- the maximum allowed by the DSC, *excluding* line
terminators -- because do_ps_file() allocates a buffer of exactly 255
bytes, which ps_get_line() will happily fill completely, before
gratuitously appending a LF plus a NUL string terminator, for a
potential overrun to 257 bytes).

The attached patch fixes this, in addition to refactoring ps_get_line()
itself, to avoid some look-ahead/push-back I/O overhead when processing
input files with CR-only line terminators, and to more readily support a
(future) alternative psbb processing path, within do_ps_file(), to
accommodate retrieval of /MediaBox bounds from PDF files.

Okay to commit?  I believe I've matched the existing style of code
layout, (which isn't entirely to my personal taste), but is the comment
style acceptable?  (I've annotated my changes considerably more
comprehensively than the original).

-- 
Regards,
Keith.

Attachment: psbb-input-refactor.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]