| 632 | } |
| 633 | |
| 634 | bool DexFileVerifier::CheckClassDataItemField(uint32_t idx, |
| 635 | uint32_t access_flags, |
| 636 | uint32_t class_access_flags, |
| 637 | dex::TypeIndex class_type_index, |
| 638 | bool expect_static) { |
| 639 | // Check for overflow. |
| 640 | if (!CheckIndex(idx, header_->field_ids_size_, "class_data_item field_idx")) { |
| 641 | return false; |
| 642 | } |
| 643 | |
| 644 | // Check that it's the right class. |
| 645 | dex::TypeIndex my_class_index = |
| 646 | (reinterpret_cast<const DexFile::FieldId*>(begin_ + header_->field_ids_off_) + idx)-> |
| 647 | class_idx_; |
| 648 | if (class_type_index != my_class_index) { |
| 649 | ErrorStringPrintf("Field's class index unexpected, %" PRIu16 "vs %" PRIu16, |
| 650 | my_class_index.index_, |
| 651 | class_type_index.index_); |
| 652 | return false; |
| 653 | } |
| 654 | |
| 655 | // Check that it falls into the right class-data list. |
| 656 | bool is_static = (access_flags & kAccStatic) != 0; |
| 657 | if (UNLIKELY(is_static != expect_static)) { |
| 658 | ErrorStringPrintf("Static/instance field not in expected list"); |
| 659 | return false; |
| 660 | } |
| 661 | |
| 662 | // Check field access flags. |
| 663 | std::string error_msg; |
| 664 | if (!CheckFieldAccessFlags(idx, access_flags, class_access_flags, &error_msg)) { |
| 665 | ErrorStringPrintf("%s", error_msg.c_str()); |
| 666 | return false; |
| 667 | } |
| 668 | |
| 669 | return true; |
| 670 | } |
| 671 | |
| 672 | bool DexFileVerifier::CheckClassDataItemMethod(uint32_t idx, |
| 673 | uint32_t access_flags, |