harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r420555 - in /incubator/harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/java/security/MessageDigest.java test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java
Date Mon, 10 Jul 2006 15:00:22 GMT
Author: tellison
Date: Mon Jul 10 08:00:21 2006
New Revision: 420555

URL: http://svn.apache.org/viewvc?rev=420555&view=rev
Log:
Fix for HARMONY-743 ([classlib][security] compatibility: unexpected ArrayIndexOutOfBoundsException
for MessageDigest.digest(byte[],Integer.MAX_VALUE,int);)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigest.java?rev=420555&r1=420554&r2=420555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/MessageDigest.java
Mon Jul 10 08:00:21 2006
@@ -165,7 +165,7 @@
      */
     public void update(byte[] input, int offset, int len) {
         if (input == null || offset < 0 || len < 0 ||
-                offset + len > input.length) {
+                (long)offset + (long)len > input.length) {
             throw new IllegalArgumentException(
                     "Incorrect offset/len parameters");
         }
@@ -201,7 +201,7 @@
      */
     public int digest(byte[] buf, int offset, int len) throws DigestException {
         if (buf == null || offset < 0 || len < 0 ||
-                offset + len > buf.length) {
+                (long)offset + (long)len > buf.length) {
             throw new IllegalArgumentException(
                     "Incorrect offset/len parameters");
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java?rev=420555&r1=420554&r2=420555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/MessageDigest2Test.java
Mon Jul 10 08:00:21 2006
@@ -289,6 +289,28 @@
 						+ " : " + e);
 			}
 		}
+        try {                
+            MessageDigest.getInstance("SHA").digest(new byte[] {}, Integer.MAX_VALUE, 755);
                                           
+        } catch (NoSuchAlgorithmException e) {
+        	//allowed
+        } catch (DigestException e) {
+        	//allowed
+        } catch (IllegalArgumentException e) {
+        	//expected
+        }
+	}
+
+	/**
+	 * @tests java.security.MessageDigest#update(byte[], int, int)
+	 */
+	public void test_update$BII() {
+        try {                
+        	MessageDigest.getInstance("SHA").update(new byte[] {},Integer.MAX_VALUE,Integer.MAX_VALUE);
+		} catch (NoSuchAlgorithmException e) {
+        	//allowed
+        } catch (IllegalArgumentException e) {
+        	//expected
+        }
 	}
 
 	/**



Mime
View raw message