harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r429568 - in /incubator/harmony/enhanced/classlib/trunk/modules/crypto/src: main/java/javax/crypto/spec/ test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/
Date Tue, 08 Aug 2006 04:35:14 GMT
Author: smishura
Date: Mon Aug  7 21:35:14 2006
New Revision: 429568

URL: http://svn.apache.org/viewvc?rev=429568&view=rev
Log:
Fix for HARMONY-1077 ([classlib][crypto] unexpected NegativeArraySizeException for javax.crypto.spec.SecretKeySpec(byte[],
int, -100, String))

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/RC5ParameterSpec.java
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/SecretKeySpec.java
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC5ParameterSpecTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/RC5ParameterSpec.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/RC5ParameterSpec.java?rev=429568&r1=429567&r2=429568&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/RC5ParameterSpec.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/RC5ParameterSpec.java
Mon Aug  7 21:35:14 2006
@@ -70,6 +70,9 @@
         if (iv == null) {
             throw new IllegalArgumentException("iv is null");
         }
+        if (offset < 0) {
+            throw new ArrayIndexOutOfBoundsException("offset is negative");
+        }
         if (iv.length - offset < 2 * (wordSize / 8)) {
             throw new IllegalArgumentException(
                     "iv.length - offset < 2 * (wordSize / 8)");

Modified: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/SecretKeySpec.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/SecretKeySpec.java?rev=429568&r1=429567&r2=429568&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/SecretKeySpec.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/spec/SecretKeySpec.java
Mon Aug  7 21:35:14 2006
@@ -69,6 +69,9 @@
     	if (key.length == 0) {
     		throw new IllegalArgumentException("key is empty");
     	}
+        if (len < 0) {
+            throw new ArrayIndexOutOfBoundsException("len is negative");
+        }
     	if ((key.length - offset < len)) {
     		throw new IllegalArgumentException("key is too short");
     	}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC5ParameterSpecTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC5ParameterSpecTest.java?rev=429568&r1=429567&r2=429568&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC5ParameterSpecTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/RC5ParameterSpecTest.java
Mon Aug  7 21:35:14 2006
@@ -123,6 +123,14 @@
         assertFalse("The change of iv specified in the constructor "
                     + "should not cause the change of internal array.",
                     iv[offset] == ps.getIV()[0]);
+
+        // Regression test for HARMONY-1077
+        try {
+            new RC5ParameterSpec(0, 9, 77, new byte[] { 2 }, -100);
+            fail("ArrayIndexOutOfBoundsException expected");
+        } catch (ArrayIndexOutOfBoundsException e) {
+            // expected
+        }
     }
 
     /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java?rev=429568&r1=429567&r2=429568&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/spec/SecretKeySpecTest.java
Mon Aug  7 21:35:14 2006
@@ -133,6 +133,14 @@
         assertFalse("The change of key specified in the constructor "
                     + "should not cause the change of internal array.",
                     key[offset] == ks.getEncoded()[0]);
+
+        // Regression test for HARMONY-1077
+        try {
+            new SecretKeySpec(new byte[] { 2 }, 4, -100, "CCC");
+            fail("ArrayIndexOutOfBoundsException expected");
+        } catch (ArrayIndexOutOfBoundsException e) {
+            //expected
+        }
     }
 
     /**



Mime
View raw message