--- old/src/share/vm/classfile/verifier.cpp 2017-04-20 09:03:32.664297676 -0400 +++ new/src/share/vm/classfile/verifier.cpp 2017-04-20 09:03:32.509265846 -0400 @@ -54,6 +54,7 @@ #define NOFAILOVER_MAJOR_VERSION 51 #define NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION 51 #define STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION 52 +#define MAX_ARRAY_DIMENSIONS 255 // Access to external entry for VerifyClassCodes - old byte code verifier @@ -2931,6 +2932,15 @@ char* arr_sig_str; if (component_type.is_array()) { // it's an array const char* component_name = component_type.name()->as_utf8(); + // Check for more than MAX_ARRAY_DIMENSIONS + int dims = 0; + while (component_name[dims] == '[') { + dims++; + } + if (dims >= MAX_ARRAY_DIMENSIONS) { + verify_error(ErrorContext::bad_code(bci), + "Illegal anewarray instruction, array has more than 255 dimensions"); + } // add one dimension to component length = (int)strlen(component_name) + 1; arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length);