Mercurial > hg > graal-jvmci-8
comparison src/share/vm/classfile/classFileParser.cpp @ 92:ebec5b9731e2
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
author | kamg |
---|---|
date | Thu, 10 Apr 2008 12:21:01 -0400 |
parents | a61af66fc99e |
children | ba764ed4b6f2 |
comparison
equal
deleted
inserted
replaced
91:a294fd0c4b38 | 92:ebec5b9731e2 |
---|---|
1357 } | 1357 } |
1358 | 1358 |
1359 // Parse additional attributes in code attribute | 1359 // Parse additional attributes in code attribute |
1360 cfs->guarantee_more(2, CHECK_(nullHandle)); // code_attributes_count | 1360 cfs->guarantee_more(2, CHECK_(nullHandle)); // code_attributes_count |
1361 u2 code_attributes_count = cfs->get_u2_fast(); | 1361 u2 code_attributes_count = cfs->get_u2_fast(); |
1362 unsigned int calculated_attribute_length = sizeof(max_stack) + | 1362 |
1363 sizeof(max_locals) + | 1363 unsigned int calculated_attribute_length = 0; |
1364 sizeof(code_length) + | 1364 |
1365 code_length + | 1365 if (_major_version > 45 || (_major_version == 45 && _minor_version > 2)) { |
1366 sizeof(exception_table_length) + | 1366 calculated_attribute_length = |
1367 sizeof(code_attributes_count) + | 1367 sizeof(max_stack) + sizeof(max_locals) + sizeof(code_length); |
1368 exception_table_length*(sizeof(u2) /* start_pc */+ | 1368 } else { |
1369 sizeof(u2) /* end_pc */ + | 1369 // max_stack, locals and length are smaller in pre-version 45.2 classes |
1370 sizeof(u2) /* handler_pc */ + | 1370 calculated_attribute_length = sizeof(u1) + sizeof(u1) + sizeof(u2); |
1371 sizeof(u2) /* catch_type_index */); | 1371 } |
1372 calculated_attribute_length += | |
1373 code_length + | |
1374 sizeof(exception_table_length) + | |
1375 sizeof(code_attributes_count) + | |
1376 exception_table_length * | |
1377 ( sizeof(u2) + // start_pc | |
1378 sizeof(u2) + // end_pc | |
1379 sizeof(u2) + // handler_pc | |
1380 sizeof(u2) ); // catch_type_index | |
1372 | 1381 |
1373 while (code_attributes_count--) { | 1382 while (code_attributes_count--) { |
1374 cfs->guarantee_more(6, CHECK_(nullHandle)); // code_attribute_name_index, code_attribute_length | 1383 cfs->guarantee_more(6, CHECK_(nullHandle)); // code_attribute_name_index, code_attribute_length |
1375 u2 code_attribute_name_index = cfs->get_u2_fast(); | 1384 u2 code_attribute_name_index = cfs->get_u2_fast(); |
1376 u4 code_attribute_length = cfs->get_u4_fast(); | 1385 u4 code_attribute_length = cfs->get_u4_fast(); |