{"record":{"id":"48777eacd00459a8","repo":"iBotPeaches/Apktool","slug":"unexpected-eof-while-skipping-chunk-header","errorCode":null,"errorMessage":"Unexpected EOF while skipping chunk header.","messagePattern":"Unexpected EOF while skipping chunk header\\.","errorType":"exception","errorClass":"EOFException","httpStatus":null,"severity":"critical","filePath":"brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResChunkPullParser.java","lineNumber":186,"sourceCode":"        }\n    }\n\n    public int skipHeader() throws IOException {\n        if (mChunkHeader == null) {\n            throw new IllegalStateException();\n        }\n        try {\n            long position = mIn.position();\n            long headerEnd = headerEnd();\n            if (position == headerEnd) {\n                return 0;\n            }\n            if (position > headerEnd) {\n                throw new IOException(\"Stream advanced past chunk header end.\");\n            }\n            return mIn.skipBytes((int) (headerEnd - position));\n        } catch (EOFException ignored) {\n            throw new EOFException(\"Unexpected EOF while skipping chunk header.\");\n        } catch (IOException ex) {\n            throw new IOException(\"Error while skipping chunk header.\", ex);\n        }\n    }\n}\n","sourceCodeStart":168,"sourceCodeEnd":192,"githubUrl":"https://github.com/iBotPeaches/Apktool/blob/79b63384d7d7e22917e6ea8b453272da7012515b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ResChunkPullParser.java#L168-L192","documentation":"Thrown by ResChunkPullParser.skipHeader() when the stream hits EOF while skipping to the end of the chunk header. The headerSize field promises more bytes than remain in the stream, so the file ends inside a chunk header — a definitively truncated or malformed binary resource file.","triggerScenarios":"A binary XML/resources.arsc file whose last bytes are cut off inside a chunk header; headerSize fields inflated by obfuscators; reading from a deflated zip entry whose stream ends early.","commonSituations":"Partially downloaded APKs; files corrupted in transfer or storage; header sizes rewritten by APK packing tools that pad incorrectly.","solutions":["Verify the file is complete: check zip integrity (unzip -t) and re-obtain the APK if CRCs fail.","Before parsing, ensure at least ResChunkHeader.SIZE bytes remain at the current offset when a new chunk is expected.","Catch EOFException at the file-parsing level and mark that resource file as broken instead of aborting the whole decode."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure enough bytes remain for the header before skipping\nlong headerEnd = parser.chunkStart() + parser.headerSize();\nif (headerEnd > totalFileSize) {\n    throw new EOFException(\"File ends inside chunk header\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    parser.skipHeader();\n} catch (EOFException ex) {\n    // file truncated inside a chunk header; mark undecodable, no retry\n}","preventionTips":["Check zip integrity before decoding so truncated entries are caught early","Treat EOF in a header as a corrupt file, never as transient","Keep source files immutable during decode (no concurrent writes)"],"tags":["android","apktool","binary-parsing","truncated-file","eof"],"backgroundTag":null,"analyzedSha":"79b63384d7d7e22917e6ea8b453272da7012515b","analyzedAt":"2026-08-14T10:43:28.812Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}