| 583 | } |
| 584 | |
| 585 | bool DexFileVerifier::CheckAndGetHandlerOffsets(const DexFile::CodeItem* code_item, |
| 586 | uint32_t* handler_offsets, uint32_t handlers_size) { |
| 587 | CodeItemDataAccessor accessor(*dex_file_, code_item); |
| 588 | const uint8_t* handlers_base = accessor.GetCatchHandlerData(); |
| 589 | |
| 590 | for (uint32_t i = 0; i < handlers_size; i++) { |
| 591 | bool catch_all; |
| 592 | size_t offset = ptr_ - handlers_base; |
| 593 | DECODE_SIGNED_CHECKED_FROM(ptr_, size); |
| 594 | |
| 595 | if (UNLIKELY((size < -65536) || (size > 65536))) { |
| 596 | ErrorStringPrintf("Invalid exception handler size: %d", size); |
| 597 | return false; |
| 598 | } |
| 599 | |
| 600 | if (size <= 0) { |
| 601 | catch_all = true; |
| 602 | size = -size; |
| 603 | } else { |
| 604 | catch_all = false; |
| 605 | } |
| 606 | |
| 607 | handler_offsets[i] = static_cast<uint32_t>(offset); |
| 608 | |
| 609 | while (size-- > 0) { |
| 610 | DECODE_UNSIGNED_CHECKED_FROM(ptr_, type_idx); |
| 611 | if (!CheckIndex(type_idx, header_->type_ids_size_, "handler type_idx")) { |
| 612 | return false; |
| 613 | } |
| 614 | |
| 615 | DECODE_UNSIGNED_CHECKED_FROM(ptr_, addr); |
| 616 | if (UNLIKELY(addr >= accessor.InsnsSizeInCodeUnits())) { |
| 617 | ErrorStringPrintf("Invalid handler addr: %x", addr); |
| 618 | return false; |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | if (catch_all) { |
| 623 | DECODE_UNSIGNED_CHECKED_FROM(ptr_, addr); |
| 624 | if (UNLIKELY(addr >= accessor.InsnsSizeInCodeUnits())) { |
| 625 | ErrorStringPrintf("Invalid handler catch_all_addr: %x", addr); |
| 626 | return false; |
| 627 | } |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | return true; |
| 632 | } |
| 633 | |
| 634 | bool DexFileVerifier::CheckClassDataItemField(uint32_t idx, |
| 635 | uint32_t access_flags, |
nothing calls this directly
no test coverage detected