# HG changeset patch # User hseigel # Date 1395253099 14400 # Node ID 1b26554a2629019b19988f19e3ee42f7bd891b3d # Parent 7d83f2b1a320061e21751abc9d2c037d4a89cb0f 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 diff -r 7d83f2b1a320 -r 1b26554a2629 src/share/vm/classfile/classFileParser.cpp --- a/src/share/vm/classfile/classFileParser.cpp Wed Mar 19 18:04:09 2014 -0400 +++ b/src/share/vm/classfile/classFileParser.cpp Wed Mar 19 14:18:19 2014 -0400 @@ -2666,18 +2666,19 @@ 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}}