[Poppler-bugs] [Bug 14126] New: pdftotext not checking success of fseek(), so gives misleading errors if input not seekable

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Fri Jan 18 09:56:12 PST 2008


http://bugs.freedesktop.org/show_bug.cgi?id=14126

           Summary: pdftotext not checking success of fseek(), so gives
                    misleading errors if input not seekable
           Product: poppler
           Version: unspecified
          Platform: Other
        OS/Version: Linux (All)
            Status: NEW
          Severity: normal
          Priority: medium
         Component: general
        AssignedTo: poppler-bugs at lists.freedesktop.org
        ReportedBy: eda at waniasset.com


Created an attachment (id=13775)
 --> (http://bugs.freedesktop.org/attachment.cgi?id=13775)
Patch to poppler-0.6.3 to check fseek() and similar calls

pdftotext fails uncleanly if its input is not seekable.  For example

cat some.pdf | pdftotext /dev/stdin out

This produces errors such as

Error: PDF file is damaged - attempting to reconstruct xref table...
Error: Couldn't find trailer dictionary
Error: Couldn't read xref table

But the PDF file is not damaged - just the file is not seekable.  pdftotext
doesn't check that its fseek() calls succeed.  In general I suggest it should
check the result of all file I/O calls and do something half-sensible on
failure.

(Instead of plain fseek() the code uses large-file-capable seek functions on
platforms that have them - those too need to be checked.)

(If you need a PDF file that reproduces this bug, you can create one with 'echo
| enscript -p - | ps2pdf - some.pdf'.  But I think it happens with pretty much
any input file.)

I attach a patch which simplemindedly solves the problem by checking all
fseek() calls and throwing an exception on failure, which produces an 'Illegal
seek' message on stderr.  This is a bit better than ignoring the failure.  You
might not want to apply this particular patch because it depends on C++
exception support, but something similar will be needed to check fseek() and
related calls for success or failure.


-- 
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Poppler-bugs mailing list