poppler/PDFDoc.cc | 54 ++++++++++++++++++++++++++++++++++++++++++------------ poppler/PDFDoc.h | 6 ++++++ poppler/XRef.cc | 9 ++++++++- poppler/XRef.h | 1 + 4 files changed, 57 insertions(+), 13 deletions(-)
New commits: commit ec2a1c3fca92a28c56911729927838f7aacf1078 Author: Albert Astals Cid <[email protected]> Date: Wed Nov 16 23:13:52 2011 +0100 xpdf303: Use the correct sizeof() for the greallocn diff --git a/poppler/XRef.cc b/poppler/XRef.cc index bcbcbc1..e1115c0 100644 --- a/poppler/XRef.cc +++ b/poppler/XRef.cc @@ -877,7 +877,7 @@ GBool XRef::constructXRef(GBool *wasReconstructed) { return gFalse; } streamEnds = (Guint *)greallocn(streamEnds, - streamEndsSize, sizeof(int)); + streamEndsSize, sizeof(Guint)); } streamEnds[streamEndsLen++] = pos; } commit 544440b9d19ce99f3a7fcacdea70999b1efc217f Author: Albert Astals Cid <[email protected]> Date: Wed Nov 16 23:09:23 2011 +0100 xpdf303: Add XRef::getPermFlags diff --git a/poppler/XRef.h b/poppler/XRef.h index 0fa49ef..ecb1706 100644 --- a/poppler/XRef.h +++ b/poppler/XRef.h @@ -96,6 +96,7 @@ public: GBool okToFillForm(GBool ignoreOwnerPW = gFalse); GBool okToAccessibility(GBool ignoreOwnerPW = gFalse); GBool okToAssemble(GBool ignoreOwnerPW = gFalse); + int getPermFlags() { return permFlags; } // Get catalog object. Object *getCatalog(Object *obj) { return fetch(rootNum, rootGen, obj); } commit b2e43e531edcecaeacf02a627c98cf7ef57f3e3c Author: Albert Astals Cid <[email protected]> Date: Wed Nov 16 23:04:04 2011 +0100 xpdf303: make strToUnsigned "safer" diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index ea87b0a..ec0f9be 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -1392,13 +1392,16 @@ PDFDoc *PDFDoc::ErrorPDFDoc(int errorCode, GooString *fileNameA) } Guint PDFDoc::strToUnsigned(char *s) { - Guint x; + Guint x, d; char *p; - int i; x = 0; - for (p = s, i = 0; *p && isdigit(*p) && i < 10; ++p, ++i) { - x = 10 * x + (*p - '0'); + for (p = s; *p && isdigit(*p & 0xff); ++p) { + d = *p - '0'; + if (x > (UINT_MAX - d) / 10) { + break; + } + x = 10 * x + d; } return x; } commit bd1513742182ed4c80d21401dd30180981879f24 Author: Albert Astals Cid <[email protected]> Date: Wed Nov 16 22:59:12 2011 +0100 xpdf303: Check xrefEntryCompressed entries to be of correct type and in bounds diff --git a/poppler/XRef.cc b/poppler/XRef.cc index d9fc031..bcbcbc1 100644 --- a/poppler/XRef.cc +++ b/poppler/XRef.cc @@ -1053,6 +1053,11 @@ Object *XRef::fetch(int num, int gen, Object *obj, std::set<int> *fetchOriginato goto err; } #endif + if (e->offset >= (Guint)size || + entries[e->offset].type != xrefEntryUncompressed) { + error(errSyntaxError, -1, "Invalid object stream"); + goto err; + } ObjectStream *objStr = NULL; ObjectStreamKey key(e->offset); commit 3bf3e82d1f3eb19a454239d8c7641fc68ff4e462 Author: Albert Astals Cid <[email protected]> Date: Wed Nov 16 22:54:17 2011 +0100 xpdf303: Adobe apparently ignores the generation number on compressed objects diff --git a/poppler/XRef.cc b/poppler/XRef.cc index 901c4bc..d9fc031 100644 --- a/poppler/XRef.cc +++ b/poppler/XRef.cc @@ -1048,9 +1048,11 @@ Object *XRef::fetch(int num, int gen, Object *obj, std::set<int> *fetchOriginato case xrefEntryCompressed: { +#if 0 // Adobe apparently ignores the generation number on compressed objects if (gen != 0) { goto err; } +#endif ObjectStream *objStr = NULL; ObjectStreamKey key(e->offset); commit 73e6f19c4e76762eb5131b168e3b24167ba126cb Author: Albert Astals Cid <[email protected]> Date: Wed Nov 16 22:29:11 2011 +0100 xpdf303: Add PDFDoc::fileNameU to windows builds diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index ca5f432..ea87b0a 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -119,11 +119,22 @@ PDFDoc::PDFDoc(GooString *fileNameA, GooString *ownerPassword, GooString *userPassword, void *guiDataA) { Object obj; int size = 0; +#ifdef _WIN32 + int n, i; +#endif init(); fileName = fileNameA; guiData = guiDataA; +#ifdef _WIN32 + n = fileName->getLength(); + fileNameU = (wchar_t *)gmallocn(n + 1, sizeof(wchar_t)); + for (i = 0; i < n; ++i) { + fileNameU[i] = (wchar_t)(fileName->getChar(i) & 0xff); + } + fileNameU[n] = L'\0'; +#endif struct stat buf; if (stat(fileName->getCString(), &buf) == 0) { @@ -157,7 +168,6 @@ PDFDoc::PDFDoc(GooString *fileNameA, GooString *ownerPassword, PDFDoc::PDFDoc(wchar_t *fileNameA, int fileNameLen, GooString *ownerPassword, GooString *userPassword, void *guiDataA) { OSVERSIONINFO version; - wchar_t fileName2[MAX_PATH + 1]; Object obj; int i; @@ -165,17 +175,15 @@ PDFDoc::PDFDoc(wchar_t *fileNameA, int fileNameLen, GooString *ownerPassword, guiData = guiDataA; - //~ file name should be stored in Unicode (?) + // save both Unicode and 8-bit copies of the file name fileName = new GooString(); + fileNameU = (wchar_t *)gmallocn(fileNameLen + 1, sizeof(wchar_t)); for (i = 0; i < fileNameLen; ++i) { fileName->append((char)fileNameA[i]); + fileNameU[i] = fileNameA[i]; } + fileNameU[fileNameLen] = L'\0'; - // zero-terminate the file name string - for (i = 0; i < fileNameLen && i < MAX_PATH; ++i) { - fileName2[i] = fileNameA[i]; - } - fileName2[i] = 0; // try to open file // NB: _wfopen is only available in NT @@ -187,7 +195,7 @@ PDFDoc::PDFDoc(wchar_t *fileNameA, int fileNameLen, GooString *ownerPassword, if (_wstat(fileName2, &buf) == 0) { size = buf.st_size; } - file = _wfopen(fileName2, L"rb"); + file = _wfopen(fileNameU, L"rb"); } else { if (_stat(fileName->getCString(), &buf) == 0) { size = buf.st_size; @@ -210,13 +218,27 @@ PDFDoc::PDFDoc(wchar_t *fileNameA, int fileNameLen, GooString *ownerPassword, PDFDoc::PDFDoc(BaseStream *strA, GooString *ownerPassword, GooString *userPassword, void *guiDataA) { +#ifdef _WIN32 + int n, i; +#endif init(); guiData = guiDataA; if (strA->getFileName()) { fileName = strA->getFileName()->copy(); +#ifdef _WIN32 + n = fileName->getLength(); + fileNameU = (wchar_t *)gmallocn(n + 1, sizeof(wchar_t)); + for (i = 0; i < n; ++i) { + fileNameU[i] = (wchar_t)(fileName->getChar(i) & 0xff); + } + fileNameU[n] = L'\0'; +#endif } else { fileName = NULL; +#ifdef _WIN32 + fileNameU = NULL; +#endif } str = strA; ok = setup(ownerPassword, userPassword); @@ -314,6 +336,11 @@ PDFDoc::~PDFDoc() { if (fileName) { delete fileName; } +#ifdef _WIN32 + if (fileNameU) { + gfree(fileNameU); + } +#endif } diff --git a/poppler/PDFDoc.h b/poppler/PDFDoc.h index 92cee78..ccb1b22 100644 --- a/poppler/PDFDoc.h +++ b/poppler/PDFDoc.h @@ -93,6 +93,9 @@ public: // Get file name. GooString *getFileName() { return fileName; } +#ifdef _WIN32 + wchar_t *getFileNameU() { return fileNameU; } +#endif // Get the linearization table. Linearization *getLinearization(); @@ -281,6 +284,9 @@ private: Guint strToUnsigned(char *s); GooString *fileName; +#ifdef _WIN32 + wchar_t *fileNameU; +#endif FILE *file; BaseStream *str; void *guiData; _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
