提交 54e8ec26 编写于 作者: K kamg

6615981: JVM class file parser incorrectly rejects class files with version < 45.2

Summary: A check on Code length did not take into account the old sizes of the max_stack, max_locals, and code_length.
Reviewed-by: phh, sbohne
上级 4cba5873
......@@ -1359,16 +1359,25 @@ methodHandle ClassFileParser::parse_method(constantPoolHandle cp, bool is_interf
// Parse additional attributes in code attribute
cfs->guarantee_more(2, CHECK_(nullHandle)); // code_attributes_count
u2 code_attributes_count = cfs->get_u2_fast();
unsigned int calculated_attribute_length = sizeof(max_stack) +
sizeof(max_locals) +
sizeof(code_length) +
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) +
sizeof(code_attributes_count) +
exception_table_length*(sizeof(u2) /* start_pc */+
sizeof(u2) /* end_pc */ +
sizeof(u2) /* handler_pc */ +
sizeof(u2) /* catch_type_index */);
exception_table_length *
( sizeof(u2) + // start_pc
sizeof(u2) + // end_pc
sizeof(u2) + // handler_pc
sizeof(u2) ); // catch_type_index
while (code_attributes_count--) {
cfs->guarantee_more(6, CHECK_(nullHandle)); // code_attribute_name_index, code_attribute_length
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册