From 07ee36d04086d83bdd59931949076c7b3715cfb8 Mon Sep 17 00:00:00 2001 From: hseigel Date: Wed, 19 Mar 2014 14:02:51 -0400 Subject: [PATCH] 8036800: Attribute OOM to correct part of code Summary: checks that the attribute_length does not exceed the length of remaining data in the class file Reviewed-by: coleenp, ahgross --- src/share/vm/classfile/classFileParser.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/share/vm/classfile/classFileParser.cpp b/src/share/vm/classfile/classFileParser.cpp index 3b1d4d290..5a8e90f32 100644 --- a/src/share/vm/classfile/classFileParser.cpp +++ b/src/share/vm/classfile/classFileParser.cpp @@ -2770,18 +2770,19 @@ void ClassFileParser::parse_classfile_bootstrap_methods_attribute(u4 attribute_b ClassFileStream* cfs = stream(); u1* current_start = cfs->current(); - cfs->guarantee_more(2, CHECK); // length + guarantee_property(attribute_byte_length > sizeof(u2), + "Invalid BootstrapMethods attribute length %u in class file %s", + attribute_byte_length, + CHECK); + + cfs->guarantee_more(attribute_byte_length, CHECK); + int attribute_array_length = cfs->get_u2_fast(); guarantee_property(_max_bootstrap_specifier_index < attribute_array_length, "Short length on BootstrapMethods in class file %s", CHECK); - guarantee_property(attribute_byte_length > sizeof(u2), - "Invalid BootstrapMethods attribute length %u in class file %s", - attribute_byte_length, - CHECK); - // The attribute contains a counted array of counted tuples of shorts, // represending bootstrap specifiers: // length*{bootstrap_method_index, argument_count*{argument_index}} -- GitLab