< prev index next >

src/share/vm/classfile/verifier.cpp

Print this page

        

*** 52,61 **** --- 52,62 ---- #include "logging/log.hpp" #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 extern "C" { typedef jboolean (*verify_byte_codes_fn_t)(JNIEnv *, jclass, char *, jint);
*** 2929,2938 **** --- 2930,2948 ---- cp_index_to_type(index, cp, CHECK_VERIFY(this)); int length; 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); arr_sig_str[0] = '['; strncpy(&arr_sig_str[1], component_name, length - 1);
< prev index next >