# HG changeset patch # User hseigel # Date 1572267348 0 # Node ID 7f27d70a2424e6208d8705ac456d45275752c6fe # Parent 77148b8bb7a16c157d9a80eae644dee3400a0749 8232890: Remove bad Code attribute parsing code Summary: Remove code that accepts illegal max_stack, max_locals, and length values for Code attribute in old class files. Reviewed-by: dholmes, lfoltan diff -r 77148b8bb7a1 -r 7f27d70a2424 src/hotspot/share/classfile/classFileParser.cpp --- a/src/hotspot/share/classfile/classFileParser.cpp Wed Oct 23 12:51:53 2019 +0200 +++ b/src/hotspot/share/classfile/classFileParser.cpp Mon Oct 28 12:55:48 2019 +0000 @@ -2448,17 +2448,10 @@ parsed_code_attribute = true; // Stack size, locals size, and code size - if (_major_version == 45 && _minor_version <= 2) { - cfs->guarantee_more(4, CHECK_NULL); - max_stack = cfs->get_u1_fast(); - max_locals = cfs->get_u1_fast(); - code_length = cfs->get_u2_fast(); - } else { - cfs->guarantee_more(8, CHECK_NULL); - max_stack = cfs->get_u2_fast(); - max_locals = cfs->get_u2_fast(); - code_length = cfs->get_u4_fast(); - } + cfs->guarantee_more(8, CHECK_NULL); + max_stack = cfs->get_u2_fast(); + max_locals = cfs->get_u2_fast(); + code_length = cfs->get_u4_fast(); if (_need_verify) { guarantee_property(args_size <= max_locals, "Arguments can't fit into locals in class file %s", @@ -2489,13 +2482,8 @@ unsigned int calculated_attribute_length = 0; - if (_major_version > 45 || (_major_version == 45 && _minor_version > 2)) { - calculated_attribute_length = - sizeof(max_stack) + sizeof(max_locals) + sizeof(code_length); - } else { - // max_stack, locals and length are smaller in pre-version 45.2 classes - calculated_attribute_length = sizeof(u1) + sizeof(u1) + sizeof(u2); - } + calculated_attribute_length = + sizeof(max_stack) + sizeof(max_locals) + sizeof(code_length); calculated_attribute_length += code_length + sizeof(exception_table_length) +