| 943 | } |
| 944 | |
| 945 | bool DexFileVerifier::FindClassIndexAndDef(uint32_t index, |
| 946 | bool is_field, |
| 947 | dex::TypeIndex* class_type_index, |
| 948 | const DexFile::ClassDef** output_class_def) { |
| 949 | DCHECK(class_type_index != nullptr); |
| 950 | DCHECK(output_class_def != nullptr); |
| 951 | |
| 952 | // First check if the index is valid. |
| 953 | if (index >= (is_field ? header_->field_ids_size_ : header_->method_ids_size_)) { |
| 954 | return false; |
| 955 | } |
| 956 | |
| 957 | // Next get the type index. |
| 958 | if (is_field) { |
| 959 | *class_type_index = |
| 960 | (reinterpret_cast<const DexFile::FieldId*>(begin_ + header_->field_ids_off_) + index)-> |
| 961 | class_idx_; |
| 962 | } else { |
| 963 | *class_type_index = |
| 964 | (reinterpret_cast<const DexFile::MethodId*>(begin_ + header_->method_ids_off_) + index)-> |
| 965 | class_idx_; |
| 966 | } |
| 967 | |
| 968 | // Check if that is valid. |
| 969 | if (class_type_index->index_ >= header_->type_ids_size_) { |
| 970 | return false; |
| 971 | } |
| 972 | |
| 973 | // Now search for the class def. This is basically a specialized version of the DexFile code, as |
| 974 | // we should not trust that this is a valid DexFile just yet. |
| 975 | const DexFile::ClassDef* class_def_begin = |
| 976 | reinterpret_cast<const DexFile::ClassDef*>(begin_ + header_->class_defs_off_); |
| 977 | for (size_t i = 0; i < header_->class_defs_size_; ++i) { |
| 978 | const DexFile::ClassDef* class_def = class_def_begin + i; |
| 979 | if (class_def->class_idx_ == *class_type_index) { |
| 980 | *output_class_def = class_def; |
| 981 | return true; |
| 982 | } |
| 983 | } |
| 984 | |
| 985 | // Didn't find the class-def, not defined here... |
| 986 | return false; |
| 987 | } |
| 988 | |
| 989 | bool DexFileVerifier::CheckOrderAndGetClassDef(bool is_field, |
| 990 | const char* type_descr, |
nothing calls this directly
no outgoing calls
no test coverage detected