8197443: ArrayIndexOutOfBoundsException in UcryptoException.getError
Reviewed-by: mullan
--- 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);