const void* fileEnd = state->fileEnd;
if ((start < fileStart) || (start > fileEnd)
|| (end < start) || (end > fileEnd)) {
- LOGW("Bad offset range for %s: 0x%x..0x%x\n", label,
+ LOGW("Bad offset range for %s: 0x%x..0x%x", label,
fileOffset(state, start), fileOffset(state, end));
return false;
}
*/
#define CHECK_INDEX(_field, _limit) { \
if ((_field) >= (_limit)) { \
- LOGW("Bad index: %s(%u) > %s(%u)\n", \
+ LOGW("Bad index: %s(%u) > %s(%u)", \
#_field, (u4)(_field), #_limit, (u4)(_limit)); \
return 0; \
} \
*/
#define CHECK_INDEX_OR_NOINDEX(_field, _limit) { \
if ((_field) != kDexNoIndex && (_field) >= (_limit)) { \
- LOGW("Bad index: %s(%u) > %s(%u)\n", \
+ LOGW("Bad index: %s(%u) > %s(%u)", \
#_field, (u4)(_field), #_limit, (u4)(_limit)); \
return 0; \
} \
SWAP_OFFSET4(pHeader->dataOff);
if (pHeader->endianTag != kDexEndianConstant) {
- LOGE("Unexpected endian_tag: 0x%x\n", pHeader->endianTag);
+ LOGE("Unexpected endian_tag: 0x%x", pHeader->endianTag);
return false;
}
static bool checkHeaderSection(const CheckState* state, u4 sectionOffset,
u4 sectionCount, u4* endOffset) {
if (sectionCount != 1) {
- LOGE("Multiple header items\n");
+ LOGE("Multiple header items");
return false;
}
if (sectionOffset != 0) {
- LOGE("Header at 0x%x; not at start of file\n", sectionOffset);
+ LOGE("Header at 0x%x; not at start of file", sectionOffset);
return false;
}
case kDexTypeEncodedArrayItem: return 1 << 16;
case kDexTypeAnnotationsDirectoryItem: return 1 << 17;
default: {
- LOGE("Unknown map item type %04x\n", mapType);
+ LOGE("Unknown map item type %04x", mapType);
return 0;
}
}
if (first) {
first = false;
} else if (lastOffset >= item->offset) {
- LOGE("Out-of-order map item: 0x%x then 0x%x\n",
+ LOGE("Out-of-order map item: 0x%x then 0x%x",
lastOffset, item->offset);
return false;
}
if (item->offset >= state->pHeader->fileSize) {
- LOGE("Map item after end of file: %x, size 0x%x\n",
+ LOGE("Map item after end of file: %x, size 0x%x",
item->offset, state->pHeader->fileSize);
return false;
}
}
if ((usedBits & bit) != 0) {
- LOGE("Duplicate map section of type 0x%x\n", item->type);
+ LOGE("Duplicate map section of type 0x%x", item->type);
return false;
}
}
if ((usedBits & mapTypeToBitMask(kDexTypeHeaderItem)) == 0) {
- LOGE("Map is missing header entry\n");
+ LOGE("Map is missing header entry");
return false;
}
if ((usedBits & mapTypeToBitMask(kDexTypeMapList)) == 0) {
- LOGE("Map is missing map_list entry\n");
+ LOGE("Map is missing map_list entry");
return false;
}
if (((usedBits & mapTypeToBitMask(kDexTypeStringIdItem)) == 0)
&& ((state->pHeader->stringIdsOff != 0)
|| (state->pHeader->stringIdsSize != 0))) {
- LOGE("Map is missing string_ids entry\n");
+ LOGE("Map is missing string_ids entry");
return false;
}
if (((usedBits & mapTypeToBitMask(kDexTypeTypeIdItem)) == 0)
&& ((state->pHeader->typeIdsOff != 0)
|| (state->pHeader->typeIdsSize != 0))) {
- LOGE("Map is missing type_ids entry\n");
+ LOGE("Map is missing type_ids entry");
return false;
}
if (((usedBits & mapTypeToBitMask(kDexTypeProtoIdItem)) == 0)
&& ((state->pHeader->protoIdsOff != 0)
|| (state->pHeader->protoIdsSize != 0))) {
- LOGE("Map is missing proto_ids entry\n");
+ LOGE("Map is missing proto_ids entry");
return false;
}
if (((usedBits & mapTypeToBitMask(kDexTypeFieldIdItem)) == 0)
&& ((state->pHeader->fieldIdsOff != 0)
|| (state->pHeader->fieldIdsSize != 0))) {
- LOGE("Map is missing field_ids entry\n");
+ LOGE("Map is missing field_ids entry");
return false;
}
if (((usedBits & mapTypeToBitMask(kDexTypeMethodIdItem)) == 0)
&& ((state->pHeader->methodIdsOff != 0)
|| (state->pHeader->methodIdsSize != 0))) {
- LOGE("Map is missing method_ids entry\n");
+ LOGE("Map is missing method_ids entry");
return false;
}
if (((usedBits & mapTypeToBitMask(kDexTypeClassDefItem)) == 0)
&& ((state->pHeader->classDefsOff != 0)
|| (state->pHeader->classDefsSize != 0))) {
- LOGE("Map is missing class_defs entry\n");
+ LOGE("Map is missing class_defs entry");
return false;
}
state->pDataMap = dexDataMapAlloc(dataItemCount);
if (state->pDataMap == NULL) {
- LOGE("Unable to allocate data map (size 0x%x)\n", dataItemCount);
+ LOGE("Unable to allocate data map (size 0x%x)", dataItemCount);
return false;
}
}
if (sectionOffset != state->pHeader->mapOff) {
- LOGE("Map not at header-defined offset: 0x%x, expected 0x%x\n",
+ LOGE("Map not at header-defined offset: 0x%x, expected 0x%x",
sectionOffset, state->pHeader->mapOff);
return false;
}
const char* s0 = dexGetStringData(state->pDexFile, item0);
const char* s1 = dexGetStringData(state->pDexFile, item);
if (dexUtf8Cmp(s0, s1) >= 0) {
- LOGE("Out-of-order string_ids: '%s' then '%s'\n", s0, s1);
+ LOGE("Out-of-order string_ids: '%s' then '%s'", s0, s1);
return NULL;
}
}
dexStringById(state->pDexFile, item->descriptorIdx);
if (!dexIsValidTypeDescriptor(descriptor)) {
- LOGE("Invalid type descriptor: '%s'\n", descriptor);
+ LOGE("Invalid type descriptor: '%s'", descriptor);
return NULL;
}
if (item0 != NULL) {
// Check ordering. This relies on string_ids being in order.
if (item0->descriptorIdx >= item->descriptorIdx) {
- LOGE("Out-of-order type_ids: 0x%x then 0x%x\n",
+ LOGE("Out-of-order type_ids: 0x%x then 0x%x",
item0->descriptorIdx, item->descriptorIdx);
return NULL;
}
switch (shorty) {
case 'V': {
if (!isReturnType) {
- LOGE("Invalid use of void\n");
+ LOGE("Invalid use of void");
return false;
}
// Fall through.
case 'S':
case 'Z': {
if ((descriptor[0] != shorty) || (descriptor[1] != '\0')) {
- LOGE("Shorty vs. primitive type mismatch: '%c', '%s'\n",
+ LOGE("Shorty vs. primitive type mismatch: '%c', '%s'",
shorty, descriptor);
return false;
}
}
case 'L': {
if ((descriptor[0] != 'L') && (descriptor[0] != '[')) {
- LOGE("Shorty vs. type mismatch: '%c', '%s'\n",
+ LOGE("Shorty vs. type mismatch: '%c', '%s'",
shorty, descriptor);
return false;
}
break;
}
default: {
- LOGE("Bogus shorty: '%c'\n", shorty);
+ LOGE("Bogus shorty: '%c'", shorty);
return false;
}
}
}
if (*shorty == '\0') {
- LOGE("Shorty is too short\n");
+ LOGE("Shorty is too short");
return NULL;
}
}
if (*shorty != '\0') {
- LOGE("Shorty is too long\n");
+ LOGE("Shorty is too long");
return NULL;
}
if (item0 != NULL) {
// Check ordering. This relies on type_ids being in order.
if (item0->returnTypeIdx > item->returnTypeIdx) {
- LOGE("Out-of-order proto_id return types\n");
+ LOGE("Out-of-order proto_id return types");
return NULL;
} else if (item0->returnTypeIdx == item->returnTypeIdx) {
bool badOrder = false;
}
if (badOrder) {
- LOGE("Out-of-order proto_id arguments\n");
+ LOGE("Out-of-order proto_id arguments");
return NULL;
}
}
s = dexStringByTypeIdx(state->pDexFile, item->classIdx);
if (!dexIsClassDescriptor(s)) {
- LOGE("Invalid descriptor for class_idx: '%s'\n", s);
+ LOGE("Invalid descriptor for class_idx: '%s'", s);
return NULL;
}
s = dexStringByTypeIdx(state->pDexFile, item->typeIdx);
if (!dexIsFieldDescriptor(s)) {
- LOGE("Invalid descriptor for type_idx: '%s'\n", s);
+ LOGE("Invalid descriptor for type_idx: '%s'", s);
return NULL;
}
s = dexStringById(state->pDexFile, item->nameIdx);
if (!dexIsValidMemberName(s)) {
- LOGE("Invalid name: '%s'\n", s);
+ LOGE("Invalid name: '%s'", s);
return NULL;
}
}
if (bogus) {
- LOGE("Out-of-order field_ids\n");
+ LOGE("Out-of-order field_ids");
return NULL;
}
}
s = dexStringByTypeIdx(state->pDexFile, item->classIdx);
if (!dexIsReferenceDescriptor(s)) {
- LOGE("Invalid descriptor for class_idx: '%s'\n", s);
+ LOGE("Invalid descriptor for class_idx: '%s'", s);
return NULL;
}
s = dexStringById(state->pDexFile, item->nameIdx);
if (!dexIsValidMemberName(s)) {
- LOGE("Invalid name: '%s'\n", s);
+ LOGE("Invalid name: '%s'", s);
return NULL;
}
}
if (bogus) {
- LOGE("Out-of-order method_ids\n");
+ LOGE("Out-of-order method_ids");
return NULL;
}
}
const char* descriptor = dexStringByTypeIdx(state->pDexFile, classIdx);
if (!dexIsClassDescriptor(descriptor)) {
- LOGE("Invalid class: '%s'\n", descriptor);
+ LOGE("Invalid class: '%s'", descriptor);
return NULL;
}
if (setDefinedClassBit(state, classIdx)) {
- LOGE("Duplicate class definition: '%s'\n", descriptor);
+ LOGE("Duplicate class definition: '%s'", descriptor);
return NULL;
}
if (item->superclassIdx != kDexNoIndex) {
descriptor = dexStringByTypeIdx(state->pDexFile, item->superclassIdx);
if (!dexIsClassDescriptor(descriptor)) {
- LOGE("Invalid superclass: '%s'\n", descriptor);
+ LOGE("Invalid superclass: '%s'", descriptor);
return NULL;
}
}
descriptor = dexStringByTypeIdx(state->pDexFile,
dexTypeListGetIdx(interfaces, i));
if (!dexIsClassDescriptor(descriptor)) {
- LOGE("Invalid interface: '%s'\n", descriptor);
+ LOGE("Invalid interface: '%s'", descriptor);
return NULL;
}
}
for (j = 0; j < i; j++) {
u4 idx2 = dexTypeListGetIdx(interfaces, j);
if (idx1 == idx2) {
- LOGE("Duplicate interface: '%s'\n",
+ LOGE("Duplicate interface: '%s'",
dexStringByTypeIdx(state->pDexFile, idx1));
return NULL;
}
}
if (!verifyClassDataIsForDef(state, item->classDataOff, item->classIdx)) {
- LOGE("Invalid class_data_item\n");
+ LOGE("Invalid class_data_item");
return NULL;
}
if (!verifyAnnotationsDirectoryIsForDef(state, item->annotationsOff,
item->classIdx)) {
- LOGE("Invalid annotations_directory_item\n");
+ LOGE("Invalid annotations_directory_item");
return NULL;
}
if (first) {
first = false;
} else if (lastIdx >= item->fieldIdx) {
- LOGE("Out-of-order field_idx: 0x%x then 0x%x\n", lastIdx,
+ LOGE("Out-of-order field_idx: 0x%x then 0x%x", lastIdx,
item->fieldIdx);
return NULL;
}
if (first) {
first = false;
} else if (lastIdx >= item->methodIdx) {
- LOGE("Out-of-order method_idx: 0x%x then 0x%x\n", lastIdx,
+ LOGE("Out-of-order method_idx: 0x%x then 0x%x", lastIdx,
item->methodIdx);
return NULL;
}
if (first) {
first = false;
} else if (lastIdx >= item->methodIdx) {
- LOGE("Out-of-order method_idx: 0x%x then 0x%x\n", lastIdx,
+ LOGE("Out-of-order method_idx: 0x%x then 0x%x", lastIdx,
item->methodIdx);
return NULL;
}
if (first) {
first = false;
} else if (lastIdx >= idx) {
- LOGE("Out-of-order entry types: 0x%x then 0x%x\n",
+ LOGE("Out-of-order entry types: 0x%x then 0x%x",
lastIdx, idx);
return NULL;
}
CHECK_INDEX(field->fieldIdx, state->pHeader->fieldIdsSize);
if (isStatic != expectStatic) {
- LOGE("Field in wrong list @ %d\n", i);
+ LOGE("Field in wrong list @ %d", i);
return false;
}
if ((accessFlags & ~ACC_FIELD_MASK) != 0) {
- LOGE("Bogus field access flags %x @ %d\n", accessFlags, i);
+ LOGE("Bogus field access flags %x @ %d", accessFlags, i);
return false;
}
}
bool allowSynchronized = (accessFlags & ACC_NATIVE) != 0;
if (isDirect != expectDirect) {
- LOGE("Method in wrong list @ %d\n", i);
+ LOGE("Method in wrong list @ %d", i);
return false;
}
if (((accessFlags & ~ACC_METHOD_MASK) != 0)
|| (isSynchronized && !allowSynchronized)) {
- LOGE("Bogus method access flags %x @ %d\n", accessFlags, i);
+ LOGE("Bogus method access flags %x @ %d", accessFlags, i);
return false;
}
if (expectCode) {
if (method->codeOff == 0) {
- LOGE("Unexpected zero code_off for access_flags %x\n",
+ LOGE("Unexpected zero code_off for access_flags %x",
accessFlags);
return false;
}
} else if (method->codeOff != 0) {
- LOGE("Unexpected non-zero code_off 0x%x for access_flags %x\n",
+ LOGE("Unexpected non-zero code_off 0x%x for access_flags %x",
method->codeOff, accessFlags);
return false;
}
classData->staticFields, true);
if (!okay) {
- LOGE("Trouble with static fields\n");
+ LOGE("Trouble with static fields");
return false;
}
classData->instanceFields, false);
if (!okay) {
- LOGE("Trouble with instance fields\n");
+ LOGE("Trouble with instance fields");
return false;
}
classData->directMethods, true);
if (!okay) {
- LOGE("Trouble with direct methods\n");
+ LOGE("Trouble with direct methods");
return false;
}
classData->virtualMethods, false);
if (!okay) {
- LOGE("Trouble with virtual methods\n");
+ LOGE("Trouble with virtual methods");
return false;
}
DexClassData* classData = dexReadAndVerifyClassData(&data, state->fileEnd);
if (classData == NULL) {
- LOGE("Unable to parse class_data_item\n");
+ LOGE("Unable to parse class_data_item");
return NULL;
}
bool catchAll;
if (!okay) {
- LOGE("Bogus size\n");
+ LOGE("Bogus size");
return 0;
}
if ((size < -65536) || (size > 65536)) {
- LOGE("Invalid size: %d\n", size);
+ LOGE("Invalid size: %d", size);
return 0;
}
readAndVerifyUnsignedLeb128(&encodedPtr, state->fileEnd, &okay);
if (!okay) {
- LOGE("Bogus handlers_size\n");
+ LOGE("Bogus handlers_size");
return NULL;
}
if ((handlersSize == 0) || (handlersSize >= 65536)) {
- LOGE("Invalid handlers_size: %d\n", handlersSize);
+ LOGE("Invalid handlers_size: %d", handlersSize);
return NULL;
}
SWAP_FIELD2(tries->handlerOff);
if (tries->startAddr < lastEnd) {
- LOGE("Out-of-order try\n");
+ LOGE("Out-of-order try");
return NULL;
}
if (tries->startAddr >= code->insnsSize) {
- LOGE("Invalid start_addr: 0x%x\n", tries->startAddr);
+ LOGE("Invalid start_addr: 0x%x", tries->startAddr);
return NULL;
}
}
if (i == handlersSize) {
- LOGE("Bogus handler offset: 0x%x\n", tries->handlerOff);
+ LOGE("Bogus handler offset: 0x%x", tries->handlerOff);
return NULL;
}
lastEnd = tries->startAddr + tries->insnCount;
if (lastEnd > code->insnsSize) {
- LOGE("Invalid insn_count: 0x%x (end addr 0x%x)\n",
+ LOGE("Invalid insn_count: 0x%x (end addr 0x%x)",
tries->insnCount, lastEnd);
return NULL;
}
SWAP_FIELD4(item->insnsSize);
if (item->insSize > item->registersSize) {
- LOGE("insSize (%u) > registersSize (%u)\n", item->insSize,
+ LOGE("insSize (%u) > registersSize (%u)", item->insSize,
item->registersSize);
return NULL;
}
* list. Longer parameter lists, though, need to be represented
* in-order in the register file.
*/
- LOGE("outsSize (%u) > registersSize (%u)\n", item->outsSize,
+ LOGE("outsSize (%u) > registersSize (%u)", item->outsSize,
item->registersSize);
return NULL;
}
if ((((u4) insns) & 3) != 0) {
// Four-byte alignment for the tries. Verify the spacer is a 0.
if (*insns != 0) {
- LOGE("Non-zero padding: 0x%x\n", (u4) *insns);
+ LOGE("Non-zero padding: 0x%x", (u4) *insns);
return NULL;
}
}
u4 i;
if (!okay) {
- LOGE("Bogus utf16_size\n");
+ LOGE("Bogus utf16_size");
return NULL;
}
for (i = 0; i < utf16Size; i++) {
if (data >= fileEnd) {
- LOGE("String data would go beyond end-of-file\n");
+ LOGE("String data would go beyond end-of-file");
return NULL;
}
case 0x00: {
// Special case of bit pattern 0xxx.
if (byte1 == 0) {
- LOGE("String shorter than indicated utf16_size 0x%x\n",
+ LOGE("String shorter than indicated utf16_size 0x%x",
utf16Size);
return NULL;
}
* Note: 1111 is valid for normal UTF-8, but not the
* modified UTF-8 used here.
*/
- LOGE("Illegal start byte 0x%x\n", byte1);
+ LOGE("Illegal start byte 0x%x", byte1);
return NULL;
}
case 0x0e: {
// Bit pattern 1110, so there are two additional bytes.
u1 byte2 = *(data++);
if ((byte2 & 0xc0) != 0x80) {
- LOGE("Illegal continuation byte 0x%x\n", byte2);
+ LOGE("Illegal continuation byte 0x%x", byte2);
return NULL;
}
u1 byte3 = *(data++);
if ((byte3 & 0xc0) != 0x80) {
- LOGE("Illegal continuation byte 0x%x\n", byte3);
+ LOGE("Illegal continuation byte 0x%x", byte3);
return NULL;
}
u2 value = ((byte1 & 0x0f) << 12) | ((byte2 & 0x3f) << 6)
| (byte3 & 0x3f);
if (value < 0x800) {
- LOGE("Illegal representation for value %x\n", value);
+ LOGE("Illegal representation for value %x", value);
return NULL;
}
break;
// Bit pattern 110x, so there is one additional byte.
u1 byte2 = *(data++);
if ((byte2 & 0xc0) != 0x80) {
- LOGE("Illegal continuation byte 0x%x\n", byte2);
+ LOGE("Illegal continuation byte 0x%x", byte2);
return NULL;
}
u2 value = ((byte1 & 0x1f) << 6) | (byte2 & 0x3f);
if ((value != 0) && (value < 0x80)) {
- LOGE("Illegal representation for value %x\n", value);
+ LOGE("Illegal representation for value %x", value);
return NULL;
}
break;
}
if (*(data++) != '\0') {
- LOGE("String longer than indicated utf16_size 0x%x\n", utf16Size);
+ LOGE("String longer than indicated utf16_size 0x%x", utf16Size);
return NULL;
}
readAndVerifyUnsignedLeb128(&data, fileEnd, &okay);
if (!okay) {
- LOGE("Bogus line_start\n");
+ LOGE("Bogus line_start");
return NULL;
}
readAndVerifyUnsignedLeb128(&data, fileEnd, &okay);
if (!okay) {
- LOGE("Bogus parameters_size\n");
+ LOGE("Bogus parameters_size");
return NULL;
}
if (parametersSize > 65536) {
- LOGE("Invalid parameters_size: 0x%x\n", parametersSize);
+ LOGE("Invalid parameters_size: 0x%x", parametersSize);
return NULL;
}
readAndVerifyUnsignedLeb128(&data, fileEnd, &okay);
if (!okay) {
- LOGE("Bogus parameter_name\n");
+ LOGE("Bogus parameter_name");
return NULL;
}
}
if (!okay) {
- LOGE("Bogus syntax for opcode %02x\n", opcode);
+ LOGE("Bogus syntax for opcode %02x", opcode);
return NULL;
}
}
u4 size = readAndVerifyUnsignedLeb128(&data, state->fileEnd, &okay);
if (!okay) {
- LOGE("Bogus encoded_array size\n");
+ LOGE("Bogus encoded_array size");
return NULL;
}
while (size--) {
data = verifyEncodedValue(state, data, crossVerify);
if (data == NULL) {
- LOGE("Bogus encoded_array value\n");
+ LOGE("Bogus encoded_array value");
return NULL;
}
}
switch (valueType) {
case kDexAnnotationByte: {
if (valueArg != 0) {
- LOGE("Bogus byte size 0x%x\n", valueArg);
+ LOGE("Bogus byte size 0x%x", valueArg);
return NULL;
}
data++;
case kDexAnnotationShort:
case kDexAnnotationChar: {
if (valueArg > 1) {
- LOGE("Bogus char/short size 0x%x\n", valueArg);
+ LOGE("Bogus char/short size 0x%x", valueArg);
return NULL;
}
data += valueArg + 1;
case kDexAnnotationInt:
case kDexAnnotationFloat: {
if (valueArg > 3) {
- LOGE("Bogus int/float size 0x%x\n", valueArg);
+ LOGE("Bogus int/float size 0x%x", valueArg);
return NULL;
}
data += valueArg + 1;
}
case kDexAnnotationString: {
if (valueArg > 3) {
- LOGE("Bogus string size 0x%x\n", valueArg);
+ LOGE("Bogus string size 0x%x", valueArg);
return NULL;
}
u4 idx = readUnsignedLittleEndian(state, &data, valueArg + 1);
}
case kDexAnnotationType: {
if (valueArg > 3) {
- LOGE("Bogus type size 0x%x\n", valueArg);
+ LOGE("Bogus type size 0x%x", valueArg);
return NULL;
}
u4 idx = readUnsignedLittleEndian(state, &data, valueArg + 1);
case kDexAnnotationField:
case kDexAnnotationEnum: {
if (valueArg > 3) {
- LOGE("Bogus field/enum size 0x%x\n", valueArg);
+ LOGE("Bogus field/enum size 0x%x", valueArg);
return NULL;
}
u4 idx = readUnsignedLittleEndian(state, &data, valueArg + 1);
}
case kDexAnnotationMethod: {
if (valueArg > 3) {
- LOGE("Bogus method size 0x%x\n", valueArg);
+ LOGE("Bogus method size 0x%x", valueArg);
return NULL;
}
u4 idx = readUnsignedLittleEndian(state, &data, valueArg + 1);
}
case kDexAnnotationArray: {
if (valueArg != 0) {
- LOGE("Bogus array value_arg 0x%x\n", valueArg);
+ LOGE("Bogus array value_arg 0x%x", valueArg);
return NULL;
}
data = verifyEncodedArray(state, data, crossVerify);
}
case kDexAnnotationAnnotation: {
if (valueArg != 0) {
- LOGE("Bogus annotation value_arg 0x%x\n", valueArg);
+ LOGE("Bogus annotation value_arg 0x%x", valueArg);
return NULL;
}
data = verifyEncodedAnnotation(state, data, crossVerify);
}
case kDexAnnotationNull: {
if (valueArg != 0) {
- LOGE("Bogus null value_arg 0x%x\n", valueArg);
+ LOGE("Bogus null value_arg 0x%x", valueArg);
return NULL;
}
// Nothing else to do for this type.
}
case kDexAnnotationBoolean: {
if (valueArg > 1) {
- LOGE("Bogus boolean value_arg 0x%x\n", valueArg);
+ LOGE("Bogus boolean value_arg 0x%x", valueArg);
return NULL;
}
// Nothing else to do for this type.
break;
}
default: {
- LOGE("Bogus value_type 0x%x\n", valueType);
+ LOGE("Bogus value_type 0x%x", valueType);
return NULL;
}
}
u4 idx = readAndVerifyUnsignedLeb128(&data, fileEnd, &okay);
if (!okay) {
- LOGE("Bogus encoded_annotation type_idx\n");
+ LOGE("Bogus encoded_annotation type_idx");
return NULL;
}
if (crossVerify) {
const char* descriptor = dexStringByTypeIdx(state->pDexFile, idx);
if (!dexIsClassDescriptor(descriptor)) {
- LOGE("Bogus annotation type: '%s'\n", descriptor);
+ LOGE("Bogus annotation type: '%s'", descriptor);
return NULL;
}
}
bool first = true;
if (!okay) {
- LOGE("Bogus encoded_annotation size\n");
+ LOGE("Bogus encoded_annotation size");
return NULL;
}
idx = readAndVerifyUnsignedLeb128(&data, fileEnd, &okay);
if (!okay) {
- LOGE("Bogus encoded_annotation name_idx\n");
+ LOGE("Bogus encoded_annotation name_idx");
return NULL;
}
if (crossVerify) {
const char* name = dexStringById(state->pDexFile, idx);
if (!dexIsValidMemberName(name)) {
- LOGE("Bogus annotation member name: '%s'\n", name);
+ LOGE("Bogus annotation member name: '%s'", name);
return NULL;
}
}
if (first) {
first = false;
} else if (lastIdx >= idx) {
- LOGE("Out-of-order encoded_annotation name_idx: 0x%x then 0x%x\n",
+ LOGE("Out-of-order encoded_annotation name_idx: 0x%x then 0x%x",
lastIdx, idx);
return NULL;
}
break;
}
default: {
- LOGE("Bogus annotation visibility: 0x%x\n", *data);
+ LOGE("Bogus annotation visibility: 0x%x", *data);
return NULL;
}
}
CHECK_OFFSET_RANGE(offset, newOffset);
while (offset < newOffset) {
if (*ptr != '\0') {
- LOGE("Non-zero padding 0x%02x @ %x\n", *ptr, offset);
+ LOGE("Non-zero padding 0x%02x @ %x", *ptr, offset);
return false;
}
ptr++;
newOffset = fileOffset(state, newPtr);
if (newPtr == NULL) {
- LOGE("Trouble with item %d @ offset 0x%x\n", i, offset);
+ LOGE("Trouble with item %d @ offset 0x%x", i, offset);
return false;
}
if (newOffset > state->fileLen) {
- LOGE("Item %d @ offset 0x%x ends out of bounds\n", i, offset);
+ LOGE("Item %d @ offset 0x%x ends out of bounds", i, offset);
return false;
}
u4 offset, u4 count, u4 expectedOffset, u4 expectedCount,
ItemVisitorFunction* func, u4 alignment, u4* nextOffset) {
if (offset != expectedOffset) {
- LOGE("Bogus offset for section: got 0x%x; expected 0x%x\n",
+ LOGE("Bogus offset for section: got 0x%x; expected 0x%x",
offset, expectedOffset);
return false;
}
if (count != expectedCount) {
- LOGE("Bogus size for section: got 0x%x; expected 0x%x\n",
+ LOGE("Bogus size for section: got 0x%x; expected 0x%x",
count, expectedCount);
return false;
}
assert(nextOffset != NULL);
if ((offset < dataStart) || (offset >= dataEnd)) {
- LOGE("Bogus offset for data subsection: 0x%x\n", offset);
+ LOGE("Bogus offset for data subsection: 0x%x", offset);
return false;
}
}
if (*nextOffset > dataEnd) {
- LOGE("Out-of-bounds end of data subsection: 0x%x\n", *nextOffset);
+ LOGE("Out-of-bounds end of data subsection: 0x%x", *nextOffset);
return false;
}
const u1* ptr = (const u1*) filePointer(state, lastOffset);
while (lastOffset < sectionOffset) {
if (*ptr != '\0') {
- LOGE("Non-zero padding 0x%02x before section start @ %x\n",
+ LOGE("Non-zero padding 0x%02x before section start @ %x",
*ptr, lastOffset);
okay = false;
break;
lastOffset++;
}
} else if (lastOffset > sectionOffset) {
- LOGE("Section overlap or out-of-order map: %x, %x\n",
+ LOGE("Section overlap or out-of-order map: %x, %x",
lastOffset, sectionOffset);
okay = false;
}
break;
}
default: {
- LOGE("Unknown map item type %04x\n", type);
+ LOGE("Unknown map item type %04x", type);
return false;
}
}
if (!okay) {
- LOGE("Swap of section type %04x failed\n", type);
+ LOGE("Swap of section type %04x failed", type);
}
item++;
break;
}
default: {
- LOGE("Unknown map item type %04x\n", item->type);
+ LOGE("Unknown map item type %04x", item->type);
return false;
}
}
if (!okay) {
- LOGE("Cross-item verify of section type %04x failed\n",
+ LOGE("Cross-item verify of section type %04x failed",
item->type);
}
bool okay = true;
memset(&state, 0, sizeof(state));
- LOGV("+++ swapping and verifying\n");
+ LOGV("+++ swapping and verifying");
/*
* Note: The caller must have verified that "len" is at least as
if (okay) {
int expectedLen = (int) SWAP4(pHeader->fileSize);
if (len < expectedLen) {
- LOGE("ERROR: Bad length: expected %d, got %d\n", expectedLen, len);
+ LOGE("ERROR: Bad length: expected %d, got %d", expectedLen, len);
okay = false;
} else if (len != expectedLen) {
- LOGW("WARNING: Odd length: expected %d, got %d\n", expectedLen,
+ LOGW("WARNING: Odd length: expected %d, got %d", expectedLen,
len);
// keep going
}
storedFileSize - nonSum);
if (adler != expectedChecksum) {
- LOGE("ERROR: bad checksum (%08lx, expected %08x)\n",
+ LOGE("ERROR: bad checksum (%08lx, expected %08x)",
adler, expectedChecksum);
okay = false;
}
state.pHeader = pHeader;
if (pHeader->headerSize < sizeof(DexHeader)) {
- LOGE("ERROR: Small header size %d, struct %d\n",
+ LOGE("ERROR: Small header size %d, struct %d",
pHeader->headerSize, (int) sizeof(DexHeader));
okay = false;
} else if (pHeader->headerSize > sizeof(DexHeader)) {
- LOGW("WARNING: Large header size %d, struct %d\n",
+ LOGW("WARNING: Large header size %d, struct %d",
pHeader->headerSize, (int) sizeof(DexHeader));
// keep going?
}
}
if (!okay) {
- LOGE("ERROR: Byte swap + verify failed\n");
+ LOGE("ERROR: Byte swap + verify failed");
}
if (state.pDataMap != NULL) {
return dexSwapAndVerify(addr, len);
}
- LOGE("ERROR: Bad magic number (0x%02x %02x %02x %02x)\n",
+ LOGE("ERROR: Bad magic number (0x%02x %02x %02x %02x)",
addr[0], addr[1], addr[2], addr[3]);
return 1;
ptr = mmap(NULL, length, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_ANON, -1, 0);
if (ptr == MAP_FAILED) {
- LOGW("mmap(%d, RW, SHARED|ANON) failed: %s\n", (int) length,
+ LOGW("mmap(%d, RW, SHARED|ANON) failed: %s", (int) length,
strerror(errno));
return NULL;
}
return ptr;
#else
- LOGE("sysCreateAnonShmem not implemented.\n");
+ LOGE("sysCreateAnonShmem not implemented.");
return NULL;
#endif
}
(void) lseek(fd, start, SEEK_SET);
if (start == (off_t) -1 || end == (off_t) -1) {
- LOGE("could not determine length of file\n");
+ LOGE("could not determine length of file");
return -1;
}
length = end - start;
if (length == 0) {
- LOGE("file is empty\n");
+ LOGE("file is empty");
return -1;
}
actual = read(fd, memPtr, length);
if (actual != length) {
- LOGE("only read %d of %d bytes\n", (int) actual, (int) length);
+ LOGE("only read %d of %d bytes", (int) actual, (int) length);
sysReleaseShmem(pMap);
return -1;
}
return 0;
#else
- LOGE("sysLoadFileInShmem not implemented.\n");
+ LOGE("sysLoadFileInShmem not implemented.");
return -1;
#endif
}
memPtr = malloc(length);
if (read(fd, memPtr, length) < 0) {
- LOGW("read(fd=%d, start=%d, length=%d) failed: %s\n", (int) length,
+ LOGW("read(fd=%d, start=%d, length=%d) failed: %s", (int) length,
fd, (int) start, strerror(errno));
return -1;
}
memPtr = mmap(NULL, length, PROT_READ, MAP_FILE | MAP_SHARED, fd, start);
if (memPtr == MAP_FAILED) {
- LOGW("mmap(%d, RO, FILE|SHARED, %d, %d) failed: %s\n", (int) length,
+ LOGW("mmap(%d, RO, FILE|SHARED, %d, %d) failed: %s", (int) length,
fd, (int) start, strerror(errno));
return -1;
}
memPtr = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_FILE | MAP_PRIVATE,
fd, start);
if (memPtr == MAP_FAILED) {
- LOGW("mmap(%d, R/W, FILE|PRIVATE, %d, %d) failed: %s\n", (int) length,
+ LOGW("mmap(%d, R/W, FILE|PRIVATE, %d, %d) failed: %s", (int) length,
fd, (int) start, strerror(errno));
return -1;
}
if (mprotect(memPtr, length, PROT_READ) < 0) {
/* this fails with EACCESS on FAT filesystems, e.g. /sdcard */
int err = errno;
- LOGV("mprotect(%p, %d, PROT_READ) failed: %s\n",
+ LOGV("mprotect(%p, %d, PROT_READ) failed: %s",
memPtr, length, strerror(err));
- LOGD("mprotect(RO) failed (%d), file will remain read-write\n", err);
+ LOGD("mprotect(RO) failed (%d), file will remain read-write", err);
}
pMap->baseAddr = pMap->addr = memPtr;
memPtr = mmap(NULL, actualLength, PROT_READ, MAP_FILE | MAP_SHARED,
fd, actualStart);
if (memPtr == MAP_FAILED) {
- LOGW("mmap(%d, R, FILE|SHARED, %d, %d) failed: %s\n",
+ LOGW("mmap(%d, R, FILE|SHARED, %d, %d) failed: %s",
(int) actualLength, fd, (int) actualStart, strerror(errno));
return -1;
}
pMap->addr = (char*)memPtr + adjust;
pMap->length = length;
- LOGVV("mmap seg (st=%d ln=%d): bp=%p bl=%d ad=%p ln=%d\n",
+ LOGVV("mmap seg (st=%d ln=%d): bp=%p bl=%d ad=%p ln=%d",
(int) start, (int) length,
pMap->baseAddr, (int) pMap->baseLength,
pMap->addr, (int) pMap->length);
return 0;
#else
- LOGE("sysMapFileSegmentInShmem not implemented.\n");
+ LOGE("sysMapFileSegmentInShmem not implemented.");
return -1;
#endif
}
if (addr < pMap->baseAddr ||
(u1*)addr >= (u1*)pMap->baseAddr + pMap->baseLength)
{
- LOGE("Attempted to change %p; map is %p - %p\n",
+ LOGE("Attempted to change %p; map is %p - %p",
addr, pMap->baseAddr, (u1*)pMap->baseAddr + pMap->baseLength);
return -1;
}
u1* alignAddr = (u1*) ((int) addr & ~(SYSTEM_PAGE_SIZE-1));
size_t alignLength = length + ((u1*) addr - alignAddr);
- //LOGI("%p/%zd --> %p/%zd\n", addr, length, alignAddr, alignLength);
+ //LOGI("%p/%zd --> %p/%zd", addr, length, alignAddr, alignLength);
int prot = wantReadWrite ? (PROT_READ|PROT_WRITE) : (PROT_READ);
if (mprotect(alignAddr, alignLength, prot) != 0) {
int err = errno;
- LOGV("mprotect (%p,%zd,%d) failed: %s\n",
+ LOGV("mprotect (%p,%zd,%d) failed: %s",
alignAddr, alignLength, prot, strerror(errno));
return (errno != 0) ? errno : -1;
}
return;
if (munmap(pMap->baseAddr, pMap->baseLength) < 0) {
- LOGW("munmap(%p, %d) failed: %s\n",
+ LOGW("munmap(%p, %d) failed: %s",
pMap->baseAddr, (int)pMap->baseLength, strerror(errno));
} else {
- LOGV("munmap(%p, %d) succeeded\n", pMap->baseAddr, pMap->baseLength);
+ LOGV("munmap(%p, %d) succeeded", pMap->baseAddr, pMap->baseLength);
pMap->baseAddr = NULL;
pMap->baseLength = 0;
}
ssize_t actual = TEMP_FAILURE_RETRY(write(fd, buf, count));
if (actual < 0) {
int err = errno;
- LOGE("%s: write failed: %s\n", logMsg, strerror(err));
+ LOGE("%s: write failed: %s", logMsg, strerror(err));
return err;
} else if (actual != (ssize_t) count) {
- LOGD("%s: partial write (will retry): (%d of %zd)\n",
+ LOGD("%s: partial write (will retry): (%d of %zd)",
logMsg, (int) actual, count);
buf = (const void*) (((const u1*) buf) + actual);
}
ssize_t actual = TEMP_FAILURE_RETRY(read(inFd, buf, getSize));
if (actual != (ssize_t) getSize) {
- LOGW("sysCopyFileToFile: copy read failed (%d vs %zd)\n",
+ LOGW("sysCopyFileToFile: copy read failed (%d vs %zd)",
(int) actual, getSize);
return -1;
}
if (ent < 0 || ent >= pArchive->mHashTableSize ||
pArchive->mHashTable[ent].name == NULL)
{
- LOGW("Zip: invalid ZipEntry %p (%ld)\n", entry, ent);
+ LOGW("Zip: invalid ZipEntry %p (%ld)", entry, ent);
return -1;
}
return ent;
*/
off_t fileLength = lseek(fd, 0, SEEK_END);
if (fileLength < kEOCDLen) {
- LOGV("Zip: length %ld is too small to be zip\n", (long) fileLength);
+ LOGV("Zip: length %ld is too small to be zip", (long) fileLength);
return -1;
}
scanBuf = (u1*) malloc(readAmount);
if (lseek(fd, searchStart, SEEK_SET) != searchStart) {
- LOGW("Zip: seek %ld failed: %s\n", (long) searchStart, strerror(errno));
+ LOGW("Zip: seek %ld failed: %s", (long) searchStart, strerror(errno));
return -1;
}
ssize_t actual = TEMP_FAILURE_RETRY(read(fd, scanBuf, readAmount));
if (actual != (ssize_t) readAmount) {
- LOGW("Zip: read %zd failed: %s\n", readAmount, strerror(errno));
+ LOGW("Zip: read %zd failed: %s", readAmount, strerror(errno));
return -1;
}
int i;
for (i = readAmount - kEOCDLen; i >= 0; i--) {
if (scanBuf[i] == 0x50 && get4LE(&scanBuf[i]) == kEOCDSignature) {
- LOGV("+++ Found EOCD at buf+%d\n", i);
+ LOGV("+++ Found EOCD at buf+%d", i);
break;
}
}
if (i < 0) {
- LOGD("Zip: EOCD not found, %s is not zip\n", debugFileName);
+ LOGD("Zip: EOCD not found, %s is not zip", debugFileName);
return -1;
}
u4 dirOffset = get4LE(eocdPtr + kEOCDFileOffset);
if ((long long) dirOffset + (long long) dirSize > (long long) eocdOffset) {
- LOGW("Zip: bad offsets (dir %ld, size %u, eocd %ld)\n",
+ LOGW("Zip: bad offsets (dir %ld, size %u, eocd %ld)",
(long) dirOffset, dirSize, (long) eocdOffset);
return -1;
}
if (numEntries == 0) {
- LOGW("Zip: empty archive?\n");
+ LOGW("Zip: empty archive?");
return -1;
}
- LOGV("+++ numEntries=%d dirSize=%d dirOffset=%d\n",
+ LOGV("+++ numEntries=%d dirSize=%d dirOffset=%d",
numEntries, dirSize, dirOffset);
/*
if (sysMapFileSegmentInShmem(fd, dirOffset, dirSize,
&pArchive->mDirectoryMap) != 0)
{
- LOGW("Zip: cd map failed\n");
+ LOGW("Zip: cd map failed");
return -1;
}
int i;
for (i = 0; i < numEntries; i++) {
if (get4LE(ptr) != kCDESignature) {
- LOGW("Zip: missed a central dir sig (at %d)\n", i);
+ LOGW("Zip: missed a central dir sig (at %d)", i);
goto bail;
}
if (ptr + kCDELen > cdPtr + cdLength) {
- LOGW("Zip: ran off the end (at %d)\n", i);
+ LOGW("Zip: ran off the end (at %d)", i);
goto bail;
}
long localHdrOffset = (long) get4LE(ptr + kCDELocalOffset);
if (localHdrOffset >= pArchive->mDirectoryOffset) {
- LOGW("Zip: bad LFH offset %ld at entry %d\n", localHdrOffset, i);
+ LOGW("Zip: bad LFH offset %ld at entry %d", localHdrOffset, i);
goto bail;
}
ptr += kCDELen + fileNameLen + extraLen + commentLen;
if ((size_t)(ptr - cdPtr) > cdLength) {
- LOGW("Zip: bad CD advance (%d vs %zd) at entry %d\n",
+ LOGW("Zip: bad CD advance (%d vs %zd) at entry %d",
(int) (ptr - cdPtr), cdLength, i);
goto bail;
}
}
- LOGV("+++ zip good scan %d entries\n", numEntries);
+ LOGV("+++ zip good scan %d entries", numEntries);
result = 0;
{
int fd, err;
- LOGV("Opening as zip '%s' %p\n", fileName, pArchive);
+ LOGV("Opening as zip '%s' %p", fileName, pArchive);
memset(pArchive, 0, sizeof(ZipArchive));
fd = open(fileName, O_RDONLY | O_BINARY, 0);
if (fd < 0) {
err = errno ? errno : -1;
- LOGV("Unable to open '%s': %s\n", fileName, strerror(err));
+ LOGV("Unable to open '%s': %s", fileName, strerror(err));
return err;
}
goto bail;
if (parseZipArchive(pArchive) != 0) {
- LOGV("Zip: parsing '%s' failed\n", debugFileName);
+ LOGV("Zip: parsing '%s' failed", debugFileName);
goto bail;
}
*/
void dexZipCloseArchive(ZipArchive* pArchive)
{
- LOGV("Closing archive %p\n", pArchive);
+ LOGV("Closing archive %p", pArchive);
if (pArchive->mFd >= 0)
close(pArchive->mFd);
ZipEntry findEntryByIndex(ZipArchive* pArchive, int idx)
{
if (idx < 0 || idx >= pArchive->mNumEntries) {
- LOGW("Invalid index %d\n", idx);
+ LOGW("Invalid index %d", idx);
return NULL;
}
if (pOffset != NULL) {
long localHdrOffset = (long) get4LE(ptr + kCDELocalOffset);
if (localHdrOffset + kLFHLen >= cdOffset) {
- LOGW("Zip: bad local hdr offset in zip\n");
+ LOGW("Zip: bad local hdr offset in zip");
return -1;
}
u1 lfhBuf[kLFHLen];
if (lseek(pArchive->mFd, localHdrOffset, SEEK_SET) != localHdrOffset) {
- LOGW("Zip: failed seeking to lfh at offset %ld\n", localHdrOffset);
+ LOGW("Zip: failed seeking to lfh at offset %ld", localHdrOffset);
return -1;
}
ssize_t actual =
TEMP_FAILURE_RETRY(read(pArchive->mFd, lfhBuf, sizeof(lfhBuf)));
if (actual != sizeof(lfhBuf)) {
- LOGW("Zip: failed reading lfh from offset %ld\n", localHdrOffset);
+ LOGW("Zip: failed reading lfh from offset %ld", localHdrOffset);
return -1;
}
if (get4LE(lfhBuf) != kLFHSignature) {
- LOGW("Zip: didn't find signature at start of lfh, offset=%ld\n",
+ LOGW("Zip: didn't find signature at start of lfh, offset=%ld",
localHdrOffset);
return -1;
}
off_t dataOffset = localHdrOffset + kLFHLen
+ get2LE(lfhBuf + kLFHNameLen) + get2LE(lfhBuf + kLFHExtraLen);
if (dataOffset >= cdOffset) {
- LOGW("Zip: bad data offset %ld in zip\n", (long) dataOffset);
+ LOGW("Zip: bad data offset %ld in zip", (long) dataOffset);
return -1;
}
/* check lengths */
if ((off_t)(dataOffset + compLen) > cdOffset) {
- LOGW("Zip: bad compressed length in zip (%ld + %zd > %ld)\n",
+ LOGW("Zip: bad compressed length in zip (%ld + %zd > %ld)",
(long) dataOffset, compLen, (long) cdOffset);
return -1;
}
if (method == kCompressStored &&
(off_t)(dataOffset + uncompLen) > cdOffset)
{
- LOGW("Zip: bad uncompressed length in zip (%ld + %zd > %ld)\n",
+ LOGW("Zip: bad uncompressed length in zip (%ld + %zd > %ld)",
(long) dataOffset, uncompLen, (long) cdOffset);
return -1;
}
zerr = inflateInit2(&zstream, -MAX_WBITS);
if (zerr != Z_OK) {
if (zerr == Z_VERSION_ERROR) {
- LOGE("Installed zlib is not compatible with linked version (%s)\n",
+ LOGE("Installed zlib is not compatible with linked version (%s)",
ZLIB_VERSION);
} else {
- LOGW("Call to inflateInit2 failed (zerr=%d)\n", zerr);
+ LOGW("Call to inflateInit2 failed (zerr=%d)", zerr);
}
goto bail;
}
ssize_t actual = TEMP_FAILURE_RETRY(read(inFd, readBuf, getSize));
if (actual != (ssize_t) getSize) {
- LOGW("Zip: inflate read failed (%d vs %zd)\n",
+ LOGW("Zip: inflate read failed (%d vs %zd)",
(int)actual, getSize);
goto z_bail;
}
/* uncompress the data */
zerr = inflate(&zstream, Z_NO_FLUSH);
if (zerr != Z_OK && zerr != Z_STREAM_END) {
- LOGW("Zip: inflate zerr=%d (nIn=%p aIn=%u nOut=%p aOut=%u)\n",
+ LOGW("Zip: inflate zerr=%d (nIn=%p aIn=%u nOut=%p aOut=%u)",
zerr, zstream.next_in, zstream.avail_in,
zstream.next_out, zstream.avail_out);
goto z_bail;
/* paranoia */
if (zstream.total_out != uncompLen) {
- LOGW("Zip: size mismatch on inflated file (%ld vs %zd)\n",
+ LOGW("Zip: size mismatch on inflated file (%ld vs %zd)",
zstream.total_out, uncompLen);
goto z_bail;
}
int result = -1;
int ent = entryToIndex(pArchive, entry);
if (ent < 0) {
- LOGW("Zip: extract can't find entry %p\n", entry);
+ LOGW("Zip: extract can't find entry %p", entry);
goto bail;
}
goto bail;
}
if (lseek(pArchive->mFd, dataOffset, SEEK_SET) != dataOffset) {
- LOGW("Zip: lseek to data at %ld failed\n", (long) dataOffset);
+ LOGW("Zip: lseek to data at %ld failed", (long) dataOffset);
goto bail;
}