Skip to content

Commit eedc99c

Browse files
author
Harold Seigel
committed
8232890: Remove bad Code attribute parsing code
Remove code that accepts illegal max_stack, max_locals, and length values for Code attribute in old class files. Reviewed-by: dholmes, lfoltan
1 parent 902858e commit eedc99c

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

src/hotspot/share/classfile/classFileParser.cpp

+6-18
Original file line numberDiff line numberDiff line change
@@ -2448,17 +2448,10 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs,
24482448
parsed_code_attribute = true;
24492449

24502450
// Stack size, locals size, and code size
2451-
if (_major_version == 45 && _minor_version <= 2) {
2452-
cfs->guarantee_more(4, CHECK_NULL);
2453-
max_stack = cfs->get_u1_fast();
2454-
max_locals = cfs->get_u1_fast();
2455-
code_length = cfs->get_u2_fast();
2456-
} else {
2457-
cfs->guarantee_more(8, CHECK_NULL);
2458-
max_stack = cfs->get_u2_fast();
2459-
max_locals = cfs->get_u2_fast();
2460-
code_length = cfs->get_u4_fast();
2461-
}
2451+
cfs->guarantee_more(8, CHECK_NULL);
2452+
max_stack = cfs->get_u2_fast();
2453+
max_locals = cfs->get_u2_fast();
2454+
code_length = cfs->get_u4_fast();
24622455
if (_need_verify) {
24632456
guarantee_property(args_size <= max_locals,
24642457
"Arguments can't fit into locals in class file %s",
@@ -2489,13 +2482,8 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs,
24892482

24902483
unsigned int calculated_attribute_length = 0;
24912484

2492-
if (_major_version > 45 || (_major_version == 45 && _minor_version > 2)) {
2493-
calculated_attribute_length =
2494-
sizeof(max_stack) + sizeof(max_locals) + sizeof(code_length);
2495-
} else {
2496-
// max_stack, locals and length are smaller in pre-version 45.2 classes
2497-
calculated_attribute_length = sizeof(u1) + sizeof(u1) + sizeof(u2);
2498-
}
2485+
calculated_attribute_length =
2486+
sizeof(max_stack) + sizeof(max_locals) + sizeof(code_length);
24992487
calculated_attribute_length +=
25002488
code_length +
25012489
sizeof(exception_table_length) +

0 commit comments

Comments
 (0)