Merge pull request #223 from fgeek/fix-dos-issue
Prevent infinite loop in readObject() function
This commit is contained in:
commit
4fc7f9d14a
|
@ -82,6 +82,10 @@ def readObject(stream, pdf):
|
||||||
# comment
|
# comment
|
||||||
while tok not in (b_('\r'), b_('\n')):
|
while tok not in (b_('\r'), b_('\n')):
|
||||||
tok = stream.read(1)
|
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)
|
tok = readNonWhitespace(stream)
|
||||||
stream.seek(-1, 1)
|
stream.seek(-1, 1)
|
||||||
return readObject(stream, pdf)
|
return readObject(stream, pdf)
|
||||||
|
|
Loading…
Reference in New Issue