PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Bug + patch: Corrupt PDF can cause infinite loop
http://forum.pdfsharp.com/viewtopic.php?f=3&t=3409
Page 1 of 1

Author:  Gerben Vos [ Thu Aug 04, 2016 2:26 pm ]
Post subject:  Bug + patch: Corrupt PDF can cause infinite loop

What happens:

http://www.stillhq.com/pdfdb/000419/data.pdf (which is corrupt) causes pdfsharp to hang in an infinite loop.

Cause:

A content stream inside 000419.pdf specifies a length that is longer than the file itself.

After reading a stream, pdfsharp will look for the endstream token. This loop does not exit if the file pointer is at or past the end of the file.

Patch:

See attachment. Patch is against PdfSharp 1.50-beta3b.

Attachments:
pdfsharp-670.zip [561 Bytes]
Downloaded 563 times

Author:  Thomas Hoevel [ Thu Aug 04, 2016 2:35 pm ]
Post subject:  Re: Bug + patch: Corrupt PDF can cause infinite loop

Hi!

Thanks for the submission. Changes look good at first glance.

I will give them a close look on Monday.

Author:  Gerben Vos [ Thu Aug 04, 2016 3:27 pm ]
Post subject:  Re: Bug + patch: Corrupt PDF can cause infinite loop

We found a few problems while running a huge batch of PDFs from our clients through PdfSharp. For now, these are the most urgent problems we found (having the process hang is pretty terrible). I hope to find some time to look at the remaining problems soon (the LZW decompression bug looks like the worst of those, but there are more).

Author:  Gerben Vos [ Thu Aug 04, 2016 3:28 pm ]
Post subject:  Re: Bug + patch: Corrupt PDF can cause infinite loop

In general, I can recommend downloading all of this PDF database and running it through PdfSharp; this should already show up a bunch of problems: http://www.stillhq.com/pdfdb/db.html .

Author:  Thomas Hoevel [ Tue Aug 16, 2016 12:22 pm ]
Post subject:  Re: Bug + patch: Corrupt PDF can cause infinite loop

Thanks for the patch and the link to the PDF DB.

That's an interesting file.
Adobe Reader says the file is corrupt and shows an empty page.
The PDF Reader from Windows 10 shows an empty page without complaining.
The Edge that comes with Windows 10 shows a page full with letter "X" without complaining.
Does that mean that Microsoft included two different PDF viewers in Windows 10 that use different code?

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/