You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2015/12/03 20:49:19 UTC
svn commit: r1717842 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java
Author: tilman
Date: Thu Dec 3 19:49:19 2015
New Revision: 1717842
URL: http://svn.apache.org/viewvc?rev=1717842&view=rev
Log:
PDFBOX-3149: skip empty imput when decrypting, as suggested by Jesse Long
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java?rev=1717842&r1=1717841&r2=1717842&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java Thu Dec 3 19:49:19 2015
@@ -245,6 +245,12 @@ public abstract class SecurityHandler
byte[] iv = new byte[16];
int ivSize = data.read(iv);
+
+ if (decrypt && ivSize == -1)
+ {
+ return;
+ }
+
if (ivSize != iv.length)
{
throw new IOException(
@@ -314,7 +320,19 @@ public abstract class SecurityHandler
if (decrypt)
{
// read IV from stream
- data.read(iv);
+ int ivSize = data.read(iv);
+
+ if (ivSize == -1)
+ {
+ return;
+ }
+
+ if (ivSize != iv.length)
+ {
+ throw new IOException(
+ "AES initialization vector not fully read: only "
+ + ivSize + " bytes read instead of " + iv.length);
+ }
}
else
{