Merge pull request #223 from fgeek/fix-dos-issue

Prevent infinite loop in readObject() function
This commit is contained in:
Matthew Stamy 2016-08-17 14:00:37 -05:00 committed by GitHub
commit 4fc7f9d14a
1 changed files with 4 additions and 0 deletions

View File

@ -82,6 +82,10 @@ def readObject(stream, pdf):
# comment
while tok not in (b_('\r'), b_('\n')):
tok = stream.read(1)
# Prevents an infinite loop by raising an error if the stream is at
# the EOF
if len(tok) <= 0:
raise PdfStreamError("File ended unexpectedly.")
tok = readNonWhitespace(stream)
stream.seek(-1, 1)
return readObject(stream, pdf)