| 2155 | } |
| 2156 | |
| 2157 | bool DexFileVerifier::CheckInterFieldIdItem() { |
| 2158 | const DexFile::FieldId* item = reinterpret_cast<const DexFile::FieldId*>(ptr_); |
| 2159 | |
| 2160 | // Check that the class descriptor is valid. |
| 2161 | LOAD_STRING_BY_TYPE(class_descriptor, item->class_idx_, "inter_field_id_item class_idx") |
| 2162 | if (UNLIKELY(!IsValidDescriptor(class_descriptor) || class_descriptor[0] != 'L')) { |
| 2163 | ErrorStringPrintf("Invalid descriptor for class_idx: '%s'", class_descriptor); |
| 2164 | return false; |
| 2165 | } |
| 2166 | |
| 2167 | // Check that the type descriptor is a valid field name. |
| 2168 | LOAD_STRING_BY_TYPE(type_descriptor, item->type_idx_, "inter_field_id_item type_idx") |
| 2169 | if (UNLIKELY(!IsValidDescriptor(type_descriptor) || type_descriptor[0] == 'V')) { |
| 2170 | ErrorStringPrintf("Invalid descriptor for type_idx: '%s'", type_descriptor); |
| 2171 | return false; |
| 2172 | } |
| 2173 | |
| 2174 | // Check that the name is valid. |
| 2175 | LOAD_STRING(descriptor, item->name_idx_, "inter_field_id_item name_idx") |
| 2176 | if (UNLIKELY(!IsValidMemberName(descriptor))) { |
| 2177 | ErrorStringPrintf("Invalid field name: '%s'", descriptor); |
| 2178 | return false; |
| 2179 | } |
| 2180 | |
| 2181 | // Check ordering between items. This relies on the other sections being in order. |
| 2182 | if (previous_item_ != nullptr) { |
| 2183 | const DexFile::FieldId* prev_item = reinterpret_cast<const DexFile::FieldId*>(previous_item_); |
| 2184 | if (UNLIKELY(prev_item->class_idx_ > item->class_idx_)) { |
| 2185 | ErrorStringPrintf("Out-of-order field_ids"); |
| 2186 | return false; |
| 2187 | } else if (prev_item->class_idx_ == item->class_idx_) { |
| 2188 | if (UNLIKELY(prev_item->name_idx_ > item->name_idx_)) { |
| 2189 | ErrorStringPrintf("Out-of-order field_ids"); |
| 2190 | return false; |
| 2191 | } else if (prev_item->name_idx_ == item->name_idx_) { |
| 2192 | if (UNLIKELY(prev_item->type_idx_ >= item->type_idx_)) { |
| 2193 | ErrorStringPrintf("Out-of-order field_ids"); |
| 2194 | return false; |
| 2195 | } |
| 2196 | } |
| 2197 | } |
| 2198 | } |
| 2199 | |
| 2200 | ptr_ += sizeof(DexFile::FieldId); |
| 2201 | return true; |
| 2202 | } |
| 2203 | |
| 2204 | bool DexFileVerifier::CheckInterMethodIdItem() { |
| 2205 | const DexFile::MethodId* item = reinterpret_cast<const DexFile::MethodId*>(ptr_); |
nothing calls this directly
no test coverage detected