[poppler] poppler/SecurityHandler.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat May 29 22:19:44 UTC 2021


 poppler/SecurityHandler.cc |   22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

New commits:
commit b4146c1bb021b48dba20ee343d8c3058ba4d756c
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sun May 30 00:14:52 2021 +0200

    Move the ownerKey/userKey padding to the correct place

diff --git a/poppler/SecurityHandler.cc b/poppler/SecurityHandler.cc
index a746f5a4..91cf72c8 100644
--- a/poppler/SecurityHandler.cc
+++ b/poppler/SecurityHandler.cc
@@ -242,6 +242,17 @@ StandardSecurityHandler::StandardSecurityHandler(PDFDoc *docA, Object *encryptDi
             } else if (!(encVersion == -1 && encRevision == -1)) {
                 error(errUnimplemented, -1, "Unsupported version/revision ({0:d}/{1:d}) of Standard security handler", encVersion, encRevision);
             }
+
+            if (encRevision <= 4) {
+                // Adobe apparently zero-pads the U value (and maybe the O value?)
+                // if it's short
+                while (ownerKey->getLength() < 32) {
+                    ownerKey->append((char)0x00);
+                }
+                while (userKey->getLength() < 32) {
+                    userKey->append((char)0x00);
+                }
+            }
         } else {
             error(errSyntaxError, -1,
                   "Invalid encryption key length. version: {0:d} - revision: {1:d} - ownerKeyLength: {2:d} - userKeyLength: {3:d} - ownerEncIsString: {4:d} - ownerEncLength: {5:d} - userEncIsString: {6:d} - userEncLength: {7:d}",
@@ -251,17 +262,6 @@ StandardSecurityHandler::StandardSecurityHandler(PDFDoc *docA, Object *encryptDi
     } else {
         error(errSyntaxError, -1, "Weird encryption info");
     }
-
-    if (encRevision <= 4) {
-        // Adobe apparently zero-pads the U value (and maybe the O value?)
-        // if it's short
-        while (ownerKey->getLength() < 32) {
-            ownerKey->append((char)0x00);
-        }
-        while (userKey->getLength() < 32) {
-            userKey->append((char)0x00);
-        }
-    }
 }
 
 StandardSecurityHandler::~StandardSecurityHandler()


More information about the poppler mailing list