| 1614 | } |
| 1615 | |
| 1616 | bool DexFileVerifier::CheckIntraSectionIterate(size_t offset, uint32_t section_count, |
| 1617 | DexFile::MapItemType type) { |
| 1618 | // Get the right alignment mask for the type of section. |
| 1619 | size_t alignment_mask; |
| 1620 | switch (type) { |
| 1621 | case DexFile::kDexTypeClassDataItem: |
| 1622 | case DexFile::kDexTypeStringDataItem: |
| 1623 | case DexFile::kDexTypeDebugInfoItem: |
| 1624 | case DexFile::kDexTypeAnnotationItem: |
| 1625 | case DexFile::kDexTypeEncodedArrayItem: |
| 1626 | alignment_mask = sizeof(uint8_t) - 1; |
| 1627 | break; |
| 1628 | default: |
| 1629 | alignment_mask = sizeof(uint32_t) - 1; |
| 1630 | break; |
| 1631 | } |
| 1632 | |
| 1633 | // Iterate through the items in the section. |
| 1634 | for (uint32_t i = 0; i < section_count; i++) { |
| 1635 | size_t aligned_offset = (offset + alignment_mask) & ~alignment_mask; |
| 1636 | |
| 1637 | // Check the padding between items. |
| 1638 | if (!CheckPadding(offset, aligned_offset, type)) { |
| 1639 | return false; |
| 1640 | } |
| 1641 | |
| 1642 | // Check depending on the section type. |
| 1643 | const uint8_t* start_ptr = ptr_; |
| 1644 | switch (type) { |
| 1645 | case DexFile::kDexTypeStringIdItem: { |
| 1646 | if (!CheckListSize(ptr_, 1, sizeof(DexFile::StringId), "string_ids")) { |
| 1647 | return false; |
| 1648 | } |
| 1649 | ptr_ += sizeof(DexFile::StringId); |
| 1650 | break; |
| 1651 | } |
| 1652 | case DexFile::kDexTypeTypeIdItem: { |
| 1653 | if (!CheckListSize(ptr_, 1, sizeof(DexFile::TypeId), "type_ids")) { |
| 1654 | return false; |
| 1655 | } |
| 1656 | ptr_ += sizeof(DexFile::TypeId); |
| 1657 | break; |
| 1658 | } |
| 1659 | case DexFile::kDexTypeProtoIdItem: { |
| 1660 | if (!CheckListSize(ptr_, 1, sizeof(DexFile::ProtoId), "proto_ids")) { |
| 1661 | return false; |
| 1662 | } |
| 1663 | ptr_ += sizeof(DexFile::ProtoId); |
| 1664 | break; |
| 1665 | } |
| 1666 | case DexFile::kDexTypeFieldIdItem: { |
| 1667 | if (!CheckListSize(ptr_, 1, sizeof(DexFile::FieldId), "field_ids")) { |
| 1668 | return false; |
| 1669 | } |
| 1670 | ptr_ += sizeof(DexFile::FieldId); |
| 1671 | break; |
| 1672 | } |
| 1673 | case DexFile::kDexTypeMethodIdItem: { |
nothing calls this directly
no test coverage detected