PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Bug + patch: Missing parenthesis causes infinite loop
https://forum.pdfsharp.net/viewtopic.php?f=3&t=3411
Page 1 of 1

Author:  Gerben Vos [ Thu Aug 04, 2016 2:49 pm ]
Post subject:  Bug + patch: Missing parenthesis causes infinite loop

What happens:

http://www.stillhq.com/pdfdb/000590/data.pdf causes pdfsharp to loop infinitely until it runs out of memory.

Cause:

Because of http://forum.pdfsharp.net/viewtopic.php?f=3&t=3410, pdfsharp fails to emit a closing parenthesis in a content stream. Then, the scanning for the end of the string results in an infinite loop.

Regardless of the previous bug, a missing end-of-string parenthesis should never result in an infinite loop.

Patch:

See attachment. Patch is against 1.50-beta3b. Note: I constructed the diff partially by hand, because CLexer.cs was inadvertently stored as UTF-16 in our local repository. I hope I made no mistakes.

The patch also fixes an error message.

Attachments:
pdfsharp-672.zip [990 Bytes]
Downloaded 146 times

Author:  Gerben Vos [ Tue Aug 09, 2016 1:33 pm ]
Post subject:  Re: Bug + patch: Missing parenthesis causes infinite loop

This program, based on the issue submission template, is enough to reproduce the problem, also for the other issues I posted. PDF files are not included; they are linked in the issues themselves.

Attachments:
PDFsharp-IssueSubmission (2).zip [14.77 KiB]
Downloaded 131 times

Author:  Thomas Hoevel [ Mon Aug 15, 2016 2:08 pm ]
Post subject:  Re: Bug + patch: Missing parenthesis causes infinite loop

Thanks for the feedback.

I think we already fixed that endless loop issue. Using the latest internal build, I cannot replicate the problem.

With respect to "cast" vs. "casted", I didn't change the comments as I consider "casted" correct in the context:
http://english.stackexchange.com/a/94570

Author:  Gerben Vos [ Mon Aug 15, 2016 2:37 pm ]
Post subject:  Re: Bug + patch: Missing parenthesis causes infinite loop

Okay, in that case I'm looking forward to a new public build, as I'm sure are many others...

I did a quick scan of all while loops in the source, and found about 10 that looked somewhat suspicious, but in that case I guess I'll hold off with further tests in that area unless we hit on a problematic PDF again.

Please note that, apart from that unimportant change in two comments, I also fixed the format string of an error message.

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