src/share/vm/classfile/classFileParser.cpp

changeset 8454
9d07e8518392
parent 8415
d109bda16490
child 8572
e828a0e2a4bc
     1.1 --- a/src/share/vm/classfile/classFileParser.cpp	Fri Jul 08 13:59:32 2016 +0100
     1.2 +++ b/src/share/vm/classfile/classFileParser.cpp	Tue Jul 12 22:31:57 2016 +0000
     1.3 @@ -537,6 +537,9 @@
     1.4            int name_index = cp->name_ref_index_at(index);
     1.5            Symbol*  name = cp->symbol_at(name_index);
     1.6            Symbol*  sig = cp->symbol_at(sig_index);
     1.7 +          guarantee_property(sig->utf8_length() != 0,
     1.8 +            "Illegal zero length constant pool entry at %d in class %s",
     1.9 +            sig_index, CHECK_(nullHandle));
    1.10            if (sig->byte_at(0) == JVM_SIGNATURE_FUNC) {
    1.11              verify_legal_method_signature(name, sig, CHECK_(nullHandle));
    1.12            } else {
    1.13 @@ -560,8 +563,9 @@
    1.14            verify_legal_field_name(name, CHECK_(nullHandle));
    1.15            if (_need_verify && _major_version >= JAVA_7_VERSION) {
    1.16              // Signature is verified above, when iterating NameAndType_info.
    1.17 -            // Need only to be sure it's the right type.
    1.18 -            if (signature->byte_at(0) == JVM_SIGNATURE_FUNC) {
    1.19 +            // Need only to be sure it's non-zero length and the right type.
    1.20 +            if (signature->utf8_length() == 0 ||
    1.21 +                signature->byte_at(0) == JVM_SIGNATURE_FUNC) {
    1.22                throwIllegalSignature(
    1.23                    "Field", name, signature, CHECK_(nullHandle));
    1.24              }
    1.25 @@ -572,8 +576,9 @@
    1.26            verify_legal_method_name(name, CHECK_(nullHandle));
    1.27            if (_need_verify && _major_version >= JAVA_7_VERSION) {
    1.28              // Signature is verified above, when iterating NameAndType_info.
    1.29 -            // Need only to be sure it's the right type.
    1.30 -            if (signature->byte_at(0) != JVM_SIGNATURE_FUNC) {
    1.31 +            // Need only to be sure it's non-zero length and the right type.
    1.32 +            if (signature->utf8_length() == 0 ||
    1.33 +                signature->byte_at(0) != JVM_SIGNATURE_FUNC) {
    1.34                throwIllegalSignature(
    1.35                    "Method", name, signature, CHECK_(nullHandle));
    1.36              }
    1.37 @@ -584,8 +589,7 @@
    1.38              // 4509014: If a class method name begins with '<', it must be "<init>".
    1.39              assert(name != NULL, "method name in constant pool is null");
    1.40              unsigned int name_len = name->utf8_length();
    1.41 -            assert(name_len > 0, "bad method name");  // already verified as legal name
    1.42 -            if (name->byte_at(0) == '<') {
    1.43 +            if (name_len != 0 && name->byte_at(0) == '<') {
    1.44                if (name != vmSymbols::object_initializer_name()) {
    1.45                  classfile_parse_error(
    1.46                    "Bad method name at constant pool index %u in class file %s",

mercurial