[poppler] poppler/poppler: PDFDoc.cc,1.1.1.1,1.2 PDFDoc.h,1.2,1.3
Albert Astals Cid
aacid at freedesktop.org
Wed Jul 6 06:29:02 PDT 2005
Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv11163/poppler
Modified Files:
PDFDoc.cc PDFDoc.h
Log Message:
Add checkFooter to check the document ends with %%EOF
Index: PDFDoc.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/PDFDoc.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- PDFDoc.cc 3 Mar 2005 19:46:03 -0000 1.1.1.1
+++ PDFDoc.cc 6 Jul 2005 13:29:00 -0000 1.2
@@ -116,6 +116,9 @@
GBool PDFDoc::setup(GooString *ownerPassword, GooString *userPassword) {
str->reset();
+ // check footer
+ if (!checkFooter()) return gFalse;
+
// check header
checkHeader();
@@ -170,6 +173,31 @@
}
}
+
+// Check for a %%EOF at the end of this stream
+GBool PDFDoc::checkFooter() {
+ // we look in the last 7 chars because it can be %%EOF %%EOF\n %%EOF\n\r etc
+ char eof[8];
+ int pos = str->getPos();
+ str->setPos(7, -1);
+ eof[0] = str->getChar();
+ eof[1] = str->getChar();
+ eof[2] = str->getChar();
+ eof[3] = str->getChar();
+ eof[4] = str->getChar();
+ eof[5] = str->getChar();
+ eof[6] = str->getChar();
+ eof[7] = '\0';
+ if (strstr(eof, "%%EOF") == NULL)
+ {
+ error(-1, "Document has not the mandatory ending %%EOF");
+ errCode = errDamaged;
+ return gFalse;
+ }
+ str->setPos(pos);
+ return gTrue;
+}
+
// Check for a PDF header on this stream. Skip past some garbage
// if necessary.
void PDFDoc::checkHeader() {
Index: PDFDoc.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/PDFDoc.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- PDFDoc.h 5 Jul 2005 12:15:04 -0000 1.2
+++ PDFDoc.h 6 Jul 2005 13:29:00 -0000 1.3
@@ -164,6 +164,7 @@
private:
GBool setup(GooString *ownerPassword, GooString *userPassword);
+ GBool checkFooter();
void checkHeader();
void getLinks(Page *page);
More information about the poppler
mailing list