xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lberna...@apache.org
Subject svn commit: r1608815 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java
Date Tue, 08 Jul 2014 14:53:30 GMT
Author: lbernardo
Date: Tue Jul  8 14:53:29 2014
New Revision: 1608815

URL: http://svn.apache.org/r1608815
Log:
FOP-2389: PDFEncryption: error when Password length>32

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java?rev=1608815&r1=1608814&r2=1608815&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFEncryptionJCE.java Tue Jul  8 14:53:29
2014
@@ -334,9 +334,13 @@ public final class PDFEncryptionJCE exte
             byte[] preparedPassword = new byte[finalLength];
             try {
                 byte[] passwordBytes = password.getBytes("UTF-8");
-                System.arraycopy(passwordBytes, 0, preparedPassword, 0, passwordBytes.length);
-                System.arraycopy(padding, 0, preparedPassword, passwordBytes.length, finalLength
-                        - passwordBytes.length);
+                if (passwordBytes.length >= finalLength) {
+                    System.arraycopy(passwordBytes, 0, preparedPassword, 0, finalLength);
+                } else {
+                    System.arraycopy(passwordBytes, 0, preparedPassword, 0, passwordBytes.length);
+                    System.arraycopy(padding, 0, preparedPassword, passwordBytes.length,
finalLength
+                            - passwordBytes.length);
+                }
                 return preparedPassword;
             } catch (UnsupportedEncodingException e) {
                 throw new UnsupportedOperationException(e);



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message