diff --git a/xpdf/xpdf/PDFDoc.cc b/xpdf/xpdf/PDFDoc.cc index 96d99c359..5a170676b 100644 --- a/xpdf/xpdf/PDFDoc.cc +++ b/xpdf/xpdf/PDFDoc.cc @@ -127,7 +127,15 @@ GBool PDFDoc::setup(GString *ownerPassword, GString *userPassword) { eof[i] = ch; } eof[i] = '\0'; - if (strstr(eof, "%%EOF") == NULL) + + bool found = false; + for (i = i - 5; i >= 0; i--) { + if (strncmp (&eof[i], "%%EOF", 5) == 0) { + found = true; + break; + } + } + if (!found) { error(-1, "Document does not have ending %%EOF"); errCode = errDamaged;