mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
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
This commit is contained in:
parent
902858e3ce
commit
eedc99c9ab
1 changed files with 6 additions and 18 deletions
|
@ -2448,17 +2448,10 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs,
|
|||
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();
|
||||
}
|
||||
if (_need_verify) {
|
||||
guarantee_property(args_size <= max_locals,
|
||||
"Arguments can't fit into locals in class file %s",
|
||||
|
@ -2489,13 +2482,8 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs,
|
|||
|
||||
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 +=
|
||||
code_length +
|
||||
sizeof(exception_table_length) +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue