pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1603566 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox: pdfwriter/COSWriter.java pdmodel/PDDocument.java
Date Wed, 18 Jun 2014 18:31:16 GMT
Author: lehmi
Date: Wed Jun 18 18:31:16 2014
New Revision: 1603566

URL: http://svn.apache.org/r1603566
Log:
PDFBOX-2082: avoid corruption when writing the signature as proposed by Štěpán Schejbal


Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=1603566&r1=1603565&r2=1603566&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Wed Jun 18
18:31:16 2014
@@ -795,8 +795,8 @@ public class COSWriter implements ICOSVi
         SignatureInterface signatureInterface = doc.getSignatureInterface();
         byte[] sign = signatureInterface.sign(signStream);
         String signature = new COSString(sign).getHexString();
-
-        if (signature.length() > signatureLength)
+        // substract 2 bytes because of the enclosing "<>"
+        if (signature.length() > signatureLength - 2)
         {
             throw new IOException("Can't write signature, not enough space");
         }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java?rev=1603566&r1=1603565&r2=1603566&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Wed Jun 18
18:31:16 2014
@@ -265,11 +265,11 @@ public class PDDocument implements Close
         int preferedSignatureSize = options.getPreferedSignatureSize();
         if (preferedSignatureSize > 0)
         {
-            sigObject.setContents(new byte[preferedSignatureSize * 2 + 2]);
+            sigObject.setContents(new byte[preferedSignatureSize]);
         }
         else
         {
-            sigObject.setContents(new byte[0x2500 * 2 + 2]);
+            sigObject.setContents(new byte[0x2500]);
         }
 
         // Reserve ByteRange



Mime
View raw message