[poppler] utils/pdfunite.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 4 13:13:33 UTC 2019


 utils/pdfunite.cc |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

New commits:
commit 7b4e372deeb716eb3fe3a54b31ed41af759224f9
Author: Marek Kasik <mkasik at redhat.com>
Date:   Mon Mar 4 12:55:12 2019 +0100

    pdfunite: Check XRef's Catalog for being a Dict
    
    Check whether Catalog from XRef is Dict for each document
    passed to pdfunite and return error if not.
    
    https://gitlab.freedesktop.org/poppler/poppler/issues/706

diff --git a/utils/pdfunite.cc b/utils/pdfunite.cc
index b0142116..23888684 100644
--- a/utils/pdfunite.cc
+++ b/utils/pdfunite.cc
@@ -165,7 +165,8 @@ int main (int argc, char *argv[])
   for (i = 1; i < argc - 1; i++) {
     GooString *gfileName = new GooString(argv[i]);
     PDFDoc *doc = new PDFDoc(gfileName, nullptr, nullptr, nullptr);
-    if (doc->isOk() && !doc->isEncrypted()) {
+    if (doc->isOk() && !doc->isEncrypted() &&
+        doc->getXRef()->getCatalog().isDict()) {
       docs.push_back(doc);
       if (doc->getPDFMajorVersion() > majorVersion) {
         majorVersion = doc->getPDFMajorVersion();
@@ -176,8 +177,13 @@ int main (int argc, char *argv[])
         }
       }
     } else if (doc->isOk()) {
-      error(errUnimplemented, -1, "Could not merge encrypted files ('{0:s}')", argv[i]);
-      return -1;
+      if (doc->isEncrypted()) {
+        error(errUnimplemented, -1, "Could not merge encrypted files ('{0:s}')", argv[i]);
+        return -1;
+      } else if (!doc->getXRef()->getCatalog().isDict()) {
+        error(errSyntaxError, -1, "XRef's Catalog is not a dictionary ('{0:s}')", argv[i]);
+        return -1;
+      }
     } else {
       error(errSyntaxError, -1, "Could not merge damaged documents ('{0:s}')", argv[i]);
       return -1;


More information about the poppler mailing list