changeset 5261:3de1b22e8efd

Merge
author asaha
date Sun, 20 Apr 2014 17:52:01 -0700
parents ae58e470eb15 2d77f0f9338a
children f28ea516eb0b
files make/hotspot_version
diffstat 2 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/classfile/classFileParser.cpp	Thu Mar 20 03:52:48 2014 -0700
+++ b/src/share/vm/classfile/classFileParser.cpp	Sun Apr 20 17:52:01 2014 -0700
@@ -961,7 +961,7 @@
             "Wrong size %u for field's Signature attribute in class file %s",
             attribute_length, CHECK);
         }
-        generic_signature_index = cfs->get_u2(CHECK);
+        generic_signature_index = parse_generic_signature_attribute(cp, CHECK);
       } else if (attribute_name == vmSymbols::tag_runtime_visible_annotations()) {
         runtime_visible_annotations_length = attribute_length;
         runtime_visible_annotations = cfs->get_u1_buffer();
@@ -2133,8 +2133,7 @@
             "Invalid Signature attribute length %u in class file %s",
             method_attribute_length, CHECK_(nullHandle));
         }
-        cfs->guarantee_more(2, CHECK_(nullHandle));  // generic_signature_index
-        generic_signature_index = cfs->get_u2_fast();
+        generic_signature_index = parse_generic_signature_attribute(cp, CHECK_(nullHandle));
       } else if (method_attribute_name == vmSymbols::tag_runtime_visible_annotations()) {
         runtime_visible_annotations_length = method_attribute_length;
         runtime_visible_annotations = cfs->get_u1_buffer();
@@ -2502,6 +2501,17 @@
   }
 }
 
+// Parse generic_signature attribute for methods and fields
+u2 ClassFileParser::parse_generic_signature_attribute(constantPoolHandle cp, TRAPS) {
+  ClassFileStream* cfs = stream();
+  cfs->guarantee_more(2, CHECK_0);  // generic_signature_index
+  u2 generic_signature_index = cfs->get_u2_fast();
+  check_property(
+    valid_symbol_at(cp, generic_signature_index),
+    "Invalid Signature attribute at constant pool index %u in class file %s",
+    generic_signature_index, CHECK_0);
+  return generic_signature_index;
+}
 
 void ClassFileParser::parse_classfile_sourcefile_attribute(constantPoolHandle cp, TRAPS) {
   ClassFileStream* cfs = stream();
--- a/src/share/vm/classfile/classFileParser.hpp	Thu Mar 20 03:52:48 2014 -0700
+++ b/src/share/vm/classfile/classFileParser.hpp	Sun Apr 20 17:52:01 2014 -0700
@@ -202,6 +202,7 @@
   typeArrayOop parse_stackmap_table(u4 code_attribute_length, TRAPS);
 
   // Classfile attribute parsing
+  u2 parse_generic_signature_attribute(constantPoolHandle cp, TRAPS);
   void parse_classfile_sourcefile_attribute(constantPoolHandle cp, TRAPS);
   void parse_classfile_source_debug_extension_attribute(constantPoolHandle cp, int length, TRAPS);
   u2   parse_classfile_inner_classes_attribute(u1* inner_classes_attribute_start,
@@ -336,6 +337,12 @@
             : cp->tag_at(index).is_klass_reference());
   }
 
+  // Checks that the cpool index is in range and is a utf8
+  bool valid_symbol_at(constantPoolHandle cp, int cpool_index) {
+    return (cp->is_within_bounds(cpool_index) &&
+            cp->tag_at(cpool_index).is_utf8());
+  }
+
  public:
   // Constructor
   ClassFileParser(ClassFileStream* st) { set_stream(st); }