You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Vladimir Ivanov (JIRA)" <ji...@apache.org> on 2006/07/04 12:25:29 UTC

[jira] Created: (HARMONY-743) [classlib][security] compatibility: unexpected ArrayIndexOutOfBoundsException for MessageDigest.digest(byte[],Integer.MAX_VALUE,int);

[classlib][security] compatibility: unexpected ArrayIndexOutOfBoundsException for MessageDigest.digest(byte[],Integer.MAX_VALUE,int);  
---------------------------------------------------------------------------------------------------------------------------------------

         Key: HARMONY-743
         URL: http://issues.apache.org/jira/browse/HARMONY-743
     Project: Harmony
        Type: Bug

  Components: Classlib  
    Reporter: Vladimir Ivanov


The Harmony throws the ArrayIndexOutOfBoundsException for methods MessageDigest.getInstance("SHA").digest(new byte[] {},Integer.MAX_VALUE,755)  and MessageDigest.getInstance("SHA").update(new byte[] {},Integer.MAX_VALUE,Integer.MAX_VALUE) while RI throws IllegalArgumentException.
============================ test.java ===============================
import java.security.*;

public class test {
    public static void main (String[] args) {                               
        try {                
                    MessageDigest.getInstance("SHA").digest(new byte[] {},Integer.MAX_VALUE,755);                                            
        } catch (Exception e) {
                e.printStackTrace();               
        }
        try {                 
                   MessageDigest.getInstance("SHA").update(new byte[] {},Integer.MAX_VALUE,Integer.MAX_VALUE);                         
        } catch (Exception e) {
                e.printStackTrace();               
        }
    }
} 
====================================================

Output:
C:\tmp\tmp17>C:\jrockit-jdk1.5.0-windows-ia32\bin\java.exe -showversion test
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))

java.lang.IllegalArgumentException: Output buffer too small for specified offset and length
        at java.security.MessageDigest.digest(MessageDigest.java:333)
        at test.main(test.java:6)
java.lang.IllegalArgumentException: Input buffer too short
        at java.security.MessageDigest.update(MessageDigest.java:267)
        at test.main(test.java:11)

C:\tmp\tmp17>C:\harmony\trunk_0427\deploy\jdk\jre\bin\java.exe -showversion test
java version 1.5 (subset)

(c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
java.lang.ArrayIndexOutOfBoundsException
        at java.lang.Throwable.<init>(Throwable.java:61)
        at java.lang.System.arraycopy(System.java:274)
        at java.lang.System.arraycopy(System.java:184)
        at java.security.MessageDigestSpi.engineDigest(MessageDigestSpi.java:110)
        at java.security.MessageDigest.digest(MessageDigest.java:208)
        at test.main(test.java:6)
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 2147483647
        at org.bouncycastle.crypto.digests.SHA1Digest.processWord(Unknown Source)
        at org.bouncycastle.crypto.digests.GeneralDigest.update(Unknown Source)
        at org.bouncycastle.jce.provider.JDKMessageDigest.engineUpdate(Unknown Source)
        at java.security.MessageDigest.update(MessageDigest.java:172)
        at test.main(test.java:11)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (HARMONY-743) [classlib][security] compatibility: unexpected ArrayIndexOutOfBoundsException for MessageDigest.digest(byte[],Integer.MAX_VALUE,int);

Posted by "Vladimir Ivanov (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-743?page=comments#action_12420200 ] 

Vladimir Ivanov commented on HARMONY-743:
-----------------------------------------

verified, thanks 

> [classlib][security] compatibility: unexpected ArrayIndexOutOfBoundsException for MessageDigest.digest(byte[],Integer.MAX_VALUE,int);
> -------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-743
>          URL: http://issues.apache.org/jira/browse/HARMONY-743
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Vladimir Ivanov
>     Assignee: Tim Ellison
>  Attachments: MessageDigest.patch, MessageDigest2Test.patch
>
> The Harmony throws the ArrayIndexOutOfBoundsException for methods MessageDigest.getInstance("SHA").digest(new byte[] {},Integer.MAX_VALUE,755)  and MessageDigest.getInstance("SHA").update(new byte[] {},Integer.MAX_VALUE,Integer.MAX_VALUE) while RI throws IllegalArgumentException.
> ============================ test.java ===============================
> import java.security.*;
> public class test {
>     public static void main (String[] args) {                               
>         try {                
>                     MessageDigest.getInstance("SHA").digest(new byte[] {},Integer.MAX_VALUE,755);                                            
>         } catch (Exception e) {
>                 e.printStackTrace();               
>         }
>         try {                 
>                    MessageDigest.getInstance("SHA").update(new byte[] {},Integer.MAX_VALUE,Integer.MAX_VALUE);                         
>         } catch (Exception e) {
>                 e.printStackTrace();               
>         }
>     }
> } 
> ====================================================
> Output:
> C:\tmp\tmp17>C:\jrockit-jdk1.5.0-windows-ia32\bin\java.exe -showversion test
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))
> java.lang.IllegalArgumentException: Output buffer too small for specified offset and length
>         at java.security.MessageDigest.digest(MessageDigest.java:333)
>         at test.main(test.java:6)
> java.lang.IllegalArgumentException: Input buffer too short
>         at java.security.MessageDigest.update(MessageDigest.java:267)
>         at test.main(test.java:11)
> C:\tmp\tmp17>C:\harmony\trunk_0427\deploy\jdk\jre\bin\java.exe -showversion test
> java version 1.5 (subset)
> (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java.lang.ArrayIndexOutOfBoundsException
>         at java.lang.Throwable.<init>(Throwable.java:61)
>         at java.lang.System.arraycopy(System.java:274)
>         at java.lang.System.arraycopy(System.java:184)
>         at java.security.MessageDigestSpi.engineDigest(MessageDigestSpi.java:110)
>         at java.security.MessageDigest.digest(MessageDigest.java:208)
>         at test.main(test.java:6)
> java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 2147483647
>         at org.bouncycastle.crypto.digests.SHA1Digest.processWord(Unknown Source)
>         at org.bouncycastle.crypto.digests.GeneralDigest.update(Unknown Source)
>         at org.bouncycastle.jce.provider.JDKMessageDigest.engineUpdate(Unknown Source)
>         at java.security.MessageDigest.update(MessageDigest.java:172)
>         at test.main(test.java:11)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Assigned: (HARMONY-743) [classlib][security] compatibility: unexpected ArrayIndexOutOfBoundsException for MessageDigest.digest(byte[],Integer.MAX_VALUE,int);

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-743?page=all ]

Tim Ellison reassigned HARMONY-743:
-----------------------------------

    Assign To: Tim Ellison

> [classlib][security] compatibility: unexpected ArrayIndexOutOfBoundsException for MessageDigest.digest(byte[],Integer.MAX_VALUE,int);
> -------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-743
>          URL: http://issues.apache.org/jira/browse/HARMONY-743
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Vladimir Ivanov
>     Assignee: Tim Ellison
>  Attachments: MessageDigest.patch, MessageDigest2Test.patch
>
> The Harmony throws the ArrayIndexOutOfBoundsException for methods MessageDigest.getInstance("SHA").digest(new byte[] {},Integer.MAX_VALUE,755)  and MessageDigest.getInstance("SHA").update(new byte[] {},Integer.MAX_VALUE,Integer.MAX_VALUE) while RI throws IllegalArgumentException.
> ============================ test.java ===============================
> import java.security.*;
> public class test {
>     public static void main (String[] args) {                               
>         try {                
>                     MessageDigest.getInstance("SHA").digest(new byte[] {},Integer.MAX_VALUE,755);                                            
>         } catch (Exception e) {
>                 e.printStackTrace();               
>         }
>         try {                 
>                    MessageDigest.getInstance("SHA").update(new byte[] {},Integer.MAX_VALUE,Integer.MAX_VALUE);                         
>         } catch (Exception e) {
>                 e.printStackTrace();               
>         }
>     }
> } 
> ====================================================
> Output:
> C:\tmp\tmp17>C:\jrockit-jdk1.5.0-windows-ia32\bin\java.exe -showversion test
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))
> java.lang.IllegalArgumentException: Output buffer too small for specified offset and length
>         at java.security.MessageDigest.digest(MessageDigest.java:333)
>         at test.main(test.java:6)
> java.lang.IllegalArgumentException: Input buffer too short
>         at java.security.MessageDigest.update(MessageDigest.java:267)
>         at test.main(test.java:11)
> C:\tmp\tmp17>C:\harmony\trunk_0427\deploy\jdk\jre\bin\java.exe -showversion test
> java version 1.5 (subset)
> (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java.lang.ArrayIndexOutOfBoundsException
>         at java.lang.Throwable.<init>(Throwable.java:61)
>         at java.lang.System.arraycopy(System.java:274)
>         at java.lang.System.arraycopy(System.java:184)
>         at java.security.MessageDigestSpi.engineDigest(MessageDigestSpi.java:110)
>         at java.security.MessageDigest.digest(MessageDigest.java:208)
>         at test.main(test.java:6)
> java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 2147483647
>         at org.bouncycastle.crypto.digests.SHA1Digest.processWord(Unknown Source)
>         at org.bouncycastle.crypto.digests.GeneralDigest.update(Unknown Source)
>         at org.bouncycastle.jce.provider.JDKMessageDigest.engineUpdate(Unknown Source)
>         at java.security.MessageDigest.update(MessageDigest.java:172)
>         at test.main(test.java:11)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (HARMONY-743) [classlib][security] compatibility: unexpected ArrayIndexOutOfBoundsException for MessageDigest.digest(byte[],Integer.MAX_VALUE,int);

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-743?page=all ]
     
Tim Ellison closed HARMONY-743:
-------------------------------


Verified by Vladimir.


> [classlib][security] compatibility: unexpected ArrayIndexOutOfBoundsException for MessageDigest.digest(byte[],Integer.MAX_VALUE,int);
> -------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-743
>          URL: http://issues.apache.org/jira/browse/HARMONY-743
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Vladimir Ivanov
>     Assignee: Tim Ellison
>  Attachments: MessageDigest.patch, MessageDigest2Test.patch
>
> The Harmony throws the ArrayIndexOutOfBoundsException for methods MessageDigest.getInstance("SHA").digest(new byte[] {},Integer.MAX_VALUE,755)  and MessageDigest.getInstance("SHA").update(new byte[] {},Integer.MAX_VALUE,Integer.MAX_VALUE) while RI throws IllegalArgumentException.
> ============================ test.java ===============================
> import java.security.*;
> public class test {
>     public static void main (String[] args) {                               
>         try {                
>                     MessageDigest.getInstance("SHA").digest(new byte[] {},Integer.MAX_VALUE,755);                                            
>         } catch (Exception e) {
>                 e.printStackTrace();               
>         }
>         try {                 
>                    MessageDigest.getInstance("SHA").update(new byte[] {},Integer.MAX_VALUE,Integer.MAX_VALUE);                         
>         } catch (Exception e) {
>                 e.printStackTrace();               
>         }
>     }
> } 
> ====================================================
> Output:
> C:\tmp\tmp17>C:\jrockit-jdk1.5.0-windows-ia32\bin\java.exe -showversion test
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))
> java.lang.IllegalArgumentException: Output buffer too small for specified offset and length
>         at java.security.MessageDigest.digest(MessageDigest.java:333)
>         at test.main(test.java:6)
> java.lang.IllegalArgumentException: Input buffer too short
>         at java.security.MessageDigest.update(MessageDigest.java:267)
>         at test.main(test.java:11)
> C:\tmp\tmp17>C:\harmony\trunk_0427\deploy\jdk\jre\bin\java.exe -showversion test
> java version 1.5 (subset)
> (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java.lang.ArrayIndexOutOfBoundsException
>         at java.lang.Throwable.<init>(Throwable.java:61)
>         at java.lang.System.arraycopy(System.java:274)
>         at java.lang.System.arraycopy(System.java:184)
>         at java.security.MessageDigestSpi.engineDigest(MessageDigestSpi.java:110)
>         at java.security.MessageDigest.digest(MessageDigest.java:208)
>         at test.main(test.java:6)
> java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 2147483647
>         at org.bouncycastle.crypto.digests.SHA1Digest.processWord(Unknown Source)
>         at org.bouncycastle.crypto.digests.GeneralDigest.update(Unknown Source)
>         at org.bouncycastle.jce.provider.JDKMessageDigest.engineUpdate(Unknown Source)
>         at java.security.MessageDigest.update(MessageDigest.java:172)
>         at test.main(test.java:11)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (HARMONY-743) [classlib][security] compatibility: unexpected ArrayIndexOutOfBoundsException for MessageDigest.digest(byte[],Integer.MAX_VALUE,int);

Posted by "Vladimir Ivanov (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-743?page=all ]

Vladimir Ivanov updated HARMONY-743:
------------------------------------

    Attachment: MessageDigest2Test.patch

unit test

> [classlib][security] compatibility: unexpected ArrayIndexOutOfBoundsException for MessageDigest.digest(byte[],Integer.MAX_VALUE,int);
> -------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-743
>          URL: http://issues.apache.org/jira/browse/HARMONY-743
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Vladimir Ivanov
>  Attachments: MessageDigest2Test.patch
>
> The Harmony throws the ArrayIndexOutOfBoundsException for methods MessageDigest.getInstance("SHA").digest(new byte[] {},Integer.MAX_VALUE,755)  and MessageDigest.getInstance("SHA").update(new byte[] {},Integer.MAX_VALUE,Integer.MAX_VALUE) while RI throws IllegalArgumentException.
> ============================ test.java ===============================
> import java.security.*;
> public class test {
>     public static void main (String[] args) {                               
>         try {                
>                     MessageDigest.getInstance("SHA").digest(new byte[] {},Integer.MAX_VALUE,755);                                            
>         } catch (Exception e) {
>                 e.printStackTrace();               
>         }
>         try {                 
>                    MessageDigest.getInstance("SHA").update(new byte[] {},Integer.MAX_VALUE,Integer.MAX_VALUE);                         
>         } catch (Exception e) {
>                 e.printStackTrace();               
>         }
>     }
> } 
> ====================================================
> Output:
> C:\tmp\tmp17>C:\jrockit-jdk1.5.0-windows-ia32\bin\java.exe -showversion test
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))
> java.lang.IllegalArgumentException: Output buffer too small for specified offset and length
>         at java.security.MessageDigest.digest(MessageDigest.java:333)
>         at test.main(test.java:6)
> java.lang.IllegalArgumentException: Input buffer too short
>         at java.security.MessageDigest.update(MessageDigest.java:267)
>         at test.main(test.java:11)
> C:\tmp\tmp17>C:\harmony\trunk_0427\deploy\jdk\jre\bin\java.exe -showversion test
> java version 1.5 (subset)
> (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java.lang.ArrayIndexOutOfBoundsException
>         at java.lang.Throwable.<init>(Throwable.java:61)
>         at java.lang.System.arraycopy(System.java:274)
>         at java.lang.System.arraycopy(System.java:184)
>         at java.security.MessageDigestSpi.engineDigest(MessageDigestSpi.java:110)
>         at java.security.MessageDigest.digest(MessageDigest.java:208)
>         at test.main(test.java:6)
> java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 2147483647
>         at org.bouncycastle.crypto.digests.SHA1Digest.processWord(Unknown Source)
>         at org.bouncycastle.crypto.digests.GeneralDigest.update(Unknown Source)
>         at org.bouncycastle.jce.provider.JDKMessageDigest.engineUpdate(Unknown Source)
>         at java.security.MessageDigest.update(MessageDigest.java:172)
>         at test.main(test.java:11)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Resolved: (HARMONY-743) [classlib][security] compatibility: unexpected ArrayIndexOutOfBoundsException for MessageDigest.digest(byte[],Integer.MAX_VALUE,int);

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-743?page=all ]
     
Tim Ellison resolved HARMONY-743:
---------------------------------

    Resolution: Fixed

Thanks Vladimir.

Fixed in SECURITY module at repo revision r420555.

Please check that this full resolves your problem.

(Boris: I chose to fix it in a slightly different way, thanks for the patch anyway)


> [classlib][security] compatibility: unexpected ArrayIndexOutOfBoundsException for MessageDigest.digest(byte[],Integer.MAX_VALUE,int);
> -------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-743
>          URL: http://issues.apache.org/jira/browse/HARMONY-743
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Vladimir Ivanov
>     Assignee: Tim Ellison
>  Attachments: MessageDigest.patch, MessageDigest2Test.patch
>
> The Harmony throws the ArrayIndexOutOfBoundsException for methods MessageDigest.getInstance("SHA").digest(new byte[] {},Integer.MAX_VALUE,755)  and MessageDigest.getInstance("SHA").update(new byte[] {},Integer.MAX_VALUE,Integer.MAX_VALUE) while RI throws IllegalArgumentException.
> ============================ test.java ===============================
> import java.security.*;
> public class test {
>     public static void main (String[] args) {                               
>         try {                
>                     MessageDigest.getInstance("SHA").digest(new byte[] {},Integer.MAX_VALUE,755);                                            
>         } catch (Exception e) {
>                 e.printStackTrace();               
>         }
>         try {                 
>                    MessageDigest.getInstance("SHA").update(new byte[] {},Integer.MAX_VALUE,Integer.MAX_VALUE);                         
>         } catch (Exception e) {
>                 e.printStackTrace();               
>         }
>     }
> } 
> ====================================================
> Output:
> C:\tmp\tmp17>C:\jrockit-jdk1.5.0-windows-ia32\bin\java.exe -showversion test
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))
> java.lang.IllegalArgumentException: Output buffer too small for specified offset and length
>         at java.security.MessageDigest.digest(MessageDigest.java:333)
>         at test.main(test.java:6)
> java.lang.IllegalArgumentException: Input buffer too short
>         at java.security.MessageDigest.update(MessageDigest.java:267)
>         at test.main(test.java:11)
> C:\tmp\tmp17>C:\harmony\trunk_0427\deploy\jdk\jre\bin\java.exe -showversion test
> java version 1.5 (subset)
> (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java.lang.ArrayIndexOutOfBoundsException
>         at java.lang.Throwable.<init>(Throwable.java:61)
>         at java.lang.System.arraycopy(System.java:274)
>         at java.lang.System.arraycopy(System.java:184)
>         at java.security.MessageDigestSpi.engineDigest(MessageDigestSpi.java:110)
>         at java.security.MessageDigest.digest(MessageDigest.java:208)
>         at test.main(test.java:6)
> java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 2147483647
>         at org.bouncycastle.crypto.digests.SHA1Digest.processWord(Unknown Source)
>         at org.bouncycastle.crypto.digests.GeneralDigest.update(Unknown Source)
>         at org.bouncycastle.jce.provider.JDKMessageDigest.engineUpdate(Unknown Source)
>         at java.security.MessageDigest.update(MessageDigest.java:172)
>         at test.main(test.java:11)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (HARMONY-743) [classlib][security] compatibility: unexpected ArrayIndexOutOfBoundsException for MessageDigest.digest(byte[],Integer.MAX_VALUE,int);

Posted by "Boris Kuznetsov (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-743?page=all ]

Boris Kuznetsov updated HARMONY-743:
------------------------------------

    Attachment: MessageDigest.patch

fix for this issue

> [classlib][security] compatibility: unexpected ArrayIndexOutOfBoundsException for MessageDigest.digest(byte[],Integer.MAX_VALUE,int);
> -------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-743
>          URL: http://issues.apache.org/jira/browse/HARMONY-743
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Vladimir Ivanov
>  Attachments: MessageDigest.patch, MessageDigest2Test.patch
>
> The Harmony throws the ArrayIndexOutOfBoundsException for methods MessageDigest.getInstance("SHA").digest(new byte[] {},Integer.MAX_VALUE,755)  and MessageDigest.getInstance("SHA").update(new byte[] {},Integer.MAX_VALUE,Integer.MAX_VALUE) while RI throws IllegalArgumentException.
> ============================ test.java ===============================
> import java.security.*;
> public class test {
>     public static void main (String[] args) {                               
>         try {                
>                     MessageDigest.getInstance("SHA").digest(new byte[] {},Integer.MAX_VALUE,755);                                            
>         } catch (Exception e) {
>                 e.printStackTrace();               
>         }
>         try {                 
>                    MessageDigest.getInstance("SHA").update(new byte[] {},Integer.MAX_VALUE,Integer.MAX_VALUE);                         
>         } catch (Exception e) {
>                 e.printStackTrace();               
>         }
>     }
> } 
> ====================================================
> Output:
> C:\tmp\tmp17>C:\jrockit-jdk1.5.0-windows-ia32\bin\java.exe -showversion test
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System optimized over throughput (initial strategy singleparpar))
> java.lang.IllegalArgumentException: Output buffer too small for specified offset and length
>         at java.security.MessageDigest.digest(MessageDigest.java:333)
>         at test.main(test.java:6)
> java.lang.IllegalArgumentException: Input buffer too short
>         at java.security.MessageDigest.update(MessageDigest.java:267)
>         at test.main(test.java:11)
> C:\tmp\tmp17>C:\harmony\trunk_0427\deploy\jdk\jre\bin\java.exe -showversion test
> java version 1.5 (subset)
> (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java.lang.ArrayIndexOutOfBoundsException
>         at java.lang.Throwable.<init>(Throwable.java:61)
>         at java.lang.System.arraycopy(System.java:274)
>         at java.lang.System.arraycopy(System.java:184)
>         at java.security.MessageDigestSpi.engineDigest(MessageDigestSpi.java:110)
>         at java.security.MessageDigest.digest(MessageDigest.java:208)
>         at test.main(test.java:6)
> java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 2147483647
>         at org.bouncycastle.crypto.digests.SHA1Digest.processWord(Unknown Source)
>         at org.bouncycastle.crypto.digests.GeneralDigest.update(Unknown Source)
>         at org.bouncycastle.jce.provider.JDKMessageDigest.engineUpdate(Unknown Source)
>         at java.security.MessageDigest.update(MessageDigest.java:172)
>         at test.main(test.java:11)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira