| 2202 | } |
| 2203 | |
| 2204 | bool DexFileVerifier::CheckInterMethodIdItem() { |
| 2205 | const DexFile::MethodId* item = reinterpret_cast<const DexFile::MethodId*>(ptr_); |
| 2206 | |
| 2207 | // Check that the class descriptor is a valid reference name. |
| 2208 | LOAD_STRING_BY_TYPE(class_descriptor, item->class_idx_, "inter_method_id_item class_idx") |
| 2209 | if (UNLIKELY(!IsValidDescriptor(class_descriptor) || (class_descriptor[0] != 'L' && |
| 2210 | class_descriptor[0] != '['))) { |
| 2211 | ErrorStringPrintf("Invalid descriptor for class_idx: '%s'", class_descriptor); |
| 2212 | return false; |
| 2213 | } |
| 2214 | |
| 2215 | // Check that the name is valid. |
| 2216 | LOAD_STRING(descriptor, item->name_idx_, "inter_method_id_item name_idx") |
| 2217 | if (UNLIKELY(!IsValidMemberName(descriptor))) { |
| 2218 | ErrorStringPrintf("Invalid method name: '%s'", descriptor); |
| 2219 | return false; |
| 2220 | } |
| 2221 | |
| 2222 | // Check that the proto id is valid. |
| 2223 | if (UNLIKELY(!CheckIndex(item->proto_idx_, dex_file_->NumProtoIds(), |
| 2224 | "inter_method_id_item proto_idx"))) { |
| 2225 | return false; |
| 2226 | } |
| 2227 | |
| 2228 | // Check ordering between items. This relies on the other sections being in order. |
| 2229 | if (previous_item_ != nullptr) { |
| 2230 | const DexFile::MethodId* prev_item = reinterpret_cast<const DexFile::MethodId*>(previous_item_); |
| 2231 | if (UNLIKELY(prev_item->class_idx_ > item->class_idx_)) { |
| 2232 | ErrorStringPrintf("Out-of-order method_ids"); |
| 2233 | return false; |
| 2234 | } else if (prev_item->class_idx_ == item->class_idx_) { |
| 2235 | if (UNLIKELY(prev_item->name_idx_ > item->name_idx_)) { |
| 2236 | ErrorStringPrintf("Out-of-order method_ids"); |
| 2237 | return false; |
| 2238 | } else if (prev_item->name_idx_ == item->name_idx_) { |
| 2239 | if (UNLIKELY(prev_item->proto_idx_ >= item->proto_idx_)) { |
| 2240 | ErrorStringPrintf("Out-of-order method_ids"); |
| 2241 | return false; |
| 2242 | } |
| 2243 | } |
| 2244 | } |
| 2245 | } |
| 2246 | |
| 2247 | ptr_ += sizeof(DexFile::MethodId); |
| 2248 | return true; |
| 2249 | } |
| 2250 | |
| 2251 | bool DexFileVerifier::CheckInterClassDefItem() { |
| 2252 | const DexFile::ClassDef* item = reinterpret_cast<const DexFile::ClassDef*>(ptr_); |
nothing calls this directly
no test coverage detected