{"record":{"id":"dd87a70e566706af","repo":"shwenzhang/AndResGuard","slug":"expected-0x-08x-got-0x-08x","errorCode":null,"errorMessage":"Expected: 0x%08x, got: 0x%08x","messagePattern":"Expected: 0x%08x, got: 0x%08x","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"AndResGuard-core/src/main/java/com/tencent/mm/util/ExtDataInput.java","lineNumber":49,"sourceCode":"    super(delegate);\n  }\n\n  public int[] readIntArray(int length) throws IOException {\n    int[] array = new int[length];\n    for (int i = 0; i < length; i++) {\n      array[i] = readInt();\n    }\n    return array;\n  }\n\n  public void skipInt() throws IOException {\n    skipBytes(4);\n  }\n\n  public void skipCheckInt(int expected) throws IOException {\n    int got = readInt();\n    if (got != expected) {\n      throw new IOException(String.format(\"Expected: 0x%08x, got: 0x%08x\", expected, got));\n    }\n  }\n\n  public void skipCheckChunkTypeInt(int expected, int possible) throws IOException {\n    int got = readInt();\n\n    if (got == possible) {\n      skipCheckChunkTypeInt(expected, -1);\n    } else if (got != expected) {\n      throw new IOException(String.format(\"Expected: 0x%08x, got: 0x%08x\", expected, got));\n    }\n  }\n\n  public void skipCheckShort(short expected) throws IOException {\n    short got = readShort();\n    if (got != expected) {\n      throw new IOException(String.format(\"Expected: 0x%08x, got: 0x%08x\", expected, got));\n    }","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/shwenzhang/AndResGuard/blob/e4df245d82f27d9a2d0dd108260a3510cbaba849/AndResGuard-core/src/main/java/com/tencent/mm/util/ExtDataInput.java#L31-L67","documentation":"ExtDataInput.skipCheckInt reads a 4-byte int from an Android resource (ARSC/AXML) stream and throws IOException if it does not equal the expected chunk/value. This is a strict structural sanity check used when parsing compiled binary resource files; a mismatch means the stream is not where the parser expects it to be.","triggerScenarios":"Calling skipCheckInt(expected) on a stream whose next 4 bytes differ from expected — typically a wrong offset, a corrupted/truncated ARSC file, or a resource format produced by a different aapt version.","commonSituations":"Parsing an APK built with a newer/older aapt whose chunk layout differs; processing a corrupt or tampered APK; a bug in an earlier skip/read leaving the stream misaligned.","solutions":["Verify the input APK/ARSC is a valid, uncorrupted file (unzip -t)","Check stream alignment: earlier read/skip calls must consume exactly the right byte counts","Update AndResGuard to a version matching the build-tools/aapt version that produced the file","Log both expected and got values (they are in the message) to identify which chunk header diverged"],"exampleFix":"// before\ninput.skipCheckInt(RES_TABLE_TYPE);\n// after\nint mark = peekedInt(input); // debug read of next int\nif (mark != RES_TABLE_TYPE) {\n    throw new IOException(\"Stream misaligned, next int=0x\" + Integer.toHexString(mark));\n}\ninput.skipCheckInt(RES_TABLE_TYPE);","handlingStrategy":"validation","validationCode":"// validate the APK before parsing\nProcess p = new ProcessBuilder(\"unzip\", \"-t\", apkPath).start();\nif (p.waitFor() != 0) throw new IllegalStateException(\"APK corrupt: \" + apkPath);","typeGuard":null,"tryCatchPattern":"try {\n    input.skipCheckInt(expected);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Expected:\")) {\n        throw new IOException(\"ARSC stream misaligned near chunk \" + e.getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Pin build-tools/aapt versions compatible with your AndResGuard version","Validate APK integrity before processing","Avoid running other APK-modifying tools before AndResGuard"],"tags":["java","io","binary-parsing","arsc"],"backgroundTag":"checksum-mismatch","analyzedSha":"e4df245d82f27d9a2d0dd108260a3510cbaba849","analyzedAt":"2026-09-12T17:49:07.798Z","contentChangedAt":"2026-09-12T17:49:07.798Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}