From f07dfdf9167f3e0694084a3c1cb7d7810f73d52d Mon Sep 17 00:00:00 2001 From: j Date: Sat, 27 Feb 2016 12:12:31 +0530 Subject: [PATCH] avoid endless loop with some corrupt pdfs --- Shared/lib/python3.4/site-packages/PyPDF2/pdf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Shared/lib/python3.4/site-packages/PyPDF2/pdf.py b/Shared/lib/python3.4/site-packages/PyPDF2/pdf.py index 7fa57a7..be8959f 100644 --- a/Shared/lib/python3.4/site-packages/PyPDF2/pdf.py +++ b/Shared/lib/python3.4/site-packages/PyPDF2/pdf.py @@ -1911,6 +1911,8 @@ class PdfFileReader(object): if stream.tell() < 2: raise utils.PdfReadError("EOL marker not found") step = min(stream.tell()-2, 8*1024) + if step < 2: + raise utils.PdfReadError("EOL marker not found") stream.seek(-step, 1) x = stream.read(step) if b_('\n') in x or b_('\r') in x: