commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1458928 - in /commons/proper/fileupload/trunk/src: main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java
Date Wed, 20 Mar 2013 16:31:16 GMT
Author: sebb
Date: Wed Mar 20 16:31:16 2013
New Revision: 1458928

URL: http://svn.apache.org/r1458928
Log:
Detect truncated input

Modified:
    commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
    commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java

Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java?rev=1458928&r1=1458927&r2=1458928&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
(original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/Base64Decoder.java
Wed Mar 20 16:31:16 2013
@@ -135,6 +135,8 @@ final class Base64Decoder {
                     outLen++;
                 }
             }
+        } else if (cachedBytes != 0){
+            throw new IOException("Invalid Base64 input: truncated");            
         }
         return outLen;
     }

Modified: commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java?rev=1458928&r1=1458927&r2=1458928&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java
(original)
+++ commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/util/mime/Base64DecoderTestCase.java
Wed Mar 20 16:31:16 2013
@@ -89,4 +89,10 @@ public final class Base64DecoderTestCase
         Base64Decoder.decode(x, new ByteArrayOutputStream());
     }
 
+    @Test(expected = IOException.class)
+    public void truncatedString() throws Exception {
+        final byte[] x = new byte[]{'n'};
+        Base64Decoder.decode(x, new ByteArrayOutputStream());
+    }
+
 }



Mime
View raw message