8197443: ArrayIndexOutOfBoundsException in UcryptoException.getError
authorapetcher
Mon, 12 Feb 2018 11:38:35 -0500
changeset 49793 a73fcbe66a57
parent 49792 cfdce76e0449
child 49794 274be83ad4b7
8197443: ArrayIndexOutOfBoundsException in UcryptoException.getError Reviewed-by: mullan
src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoException.java
--- a/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoException.java	Fri Feb 02 10:56:12 2018 -0800
+++ b/src/jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto/UcryptoException.java	Mon Feb 12 11:38:35 2018 -0500
@@ -134,7 +134,7 @@
      * Get the error enum value (if any) associated with this exception.
      */
     public Error getError() {
-        return errorCode < ALL_ERRORS.length ?
+        return (errorCode >= 0 && errorCode < ALL_ERRORS.length) ?
             ALL_ERRORS[errorCode] :
             null;
     }
@@ -154,7 +154,7 @@
      */
     static String getErrorMessage(int errorCode) {
         String message;
-        if (errorCode < ALL_ERRORS.length) {
+        if (errorCode >= 0 && errorCode < ALL_ERRORS.length) {
             message = ALL_ERRORS[errorCode].name();
         } else {
             message = "0x" + Integer.toHexString(errorCode);