MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / CheckEncodedValue

Method CheckEncodedValue

Bcore/src/main/cpp/dex/dex_file_verifier.cc:761–901  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759}
760
761bool DexFileVerifier::CheckEncodedValue() {
762 if (!CheckListSize(ptr_, 1, sizeof(uint8_t), "encoded_value header")) {
763 return false;
764 }
765
766 uint8_t header_byte = *(ptr_++);
767 uint32_t value_type = header_byte & DexFile::kDexAnnotationValueTypeMask;
768 uint32_t value_arg = header_byte >> DexFile::kDexAnnotationValueArgShift;
769
770 switch (value_type) {
771 case DexFile::kDexAnnotationByte:
772 if (UNLIKELY(value_arg != 0)) {
773 ErrorStringPrintf("Bad encoded_value byte size %x", value_arg);
774 return false;
775 }
776 ptr_++;
777 break;
778 case DexFile::kDexAnnotationShort:
779 case DexFile::kDexAnnotationChar:
780 if (UNLIKELY(value_arg > 1)) {
781 ErrorStringPrintf("Bad encoded_value char/short size %x", value_arg);
782 return false;
783 }
784 ptr_ += value_arg + 1;
785 break;
786 case DexFile::kDexAnnotationInt:
787 case DexFile::kDexAnnotationFloat:
788 if (UNLIKELY(value_arg > 3)) {
789 ErrorStringPrintf("Bad encoded_value int/float size %x", value_arg);
790 return false;
791 }
792 ptr_ += value_arg + 1;
793 break;
794 case DexFile::kDexAnnotationLong:
795 case DexFile::kDexAnnotationDouble:
796 ptr_ += value_arg + 1;
797 break;
798 case DexFile::kDexAnnotationString: {
799 if (UNLIKELY(value_arg > 3)) {
800 ErrorStringPrintf("Bad encoded_value string size %x", value_arg);
801 return false;
802 }
803 uint32_t idx = ReadUnsignedLittleEndian(value_arg + 1);
804 if (!CheckIndex(idx, header_->string_ids_size_, "encoded_value string")) {
805 return false;
806 }
807 break;
808 }
809 case DexFile::kDexAnnotationType: {
810 if (UNLIKELY(value_arg > 3)) {
811 ErrorStringPrintf("Bad encoded_value type size %x", value_arg);
812 return false;
813 }
814 uint32_t idx = ReadUnsignedLittleEndian(value_arg + 1);
815 if (!CheckIndex(idx, header_->type_ids_size_, "encoded_value type")) {
816 return false;
817 }
818 break;

Callers

nothing calls this directly

Calls 1

NumMethodHandlesMethod · 0.80

Tested by

no test coverage detected