{"record":{"id":"3e02b4c7df2136ba","repo":"pxb1988/dex2jar","slug":"signature-not-found-was","errorCode":null,"errorMessage":" signature not found; was ","messagePattern":" signature not found; was ","errorType":"exception","errorClass":"ZipException","httpStatus":null,"severity":"error","filePath":"dex-reader/src/main/java/com/googlecode/d2j/util/zip/ZipFile.java","lineNumber":270,"sourceCode":"        // We have to do this now (from the constructor) rather than lazily because the\n        // public API doesn't allow us to throw IOException except from the constructor\n        // or from getInputStream.\n        ByteBuffer buf = (ByteBuffer) raf.duplicate().order(ByteOrder.LITTLE_ENDIAN).position((int) centralDirOffset);\n        entries = new ArrayList<>(numEntries);\n        for (int i = 0; i < numEntries; ++i) {\n            ZipEntry newEntry = new ZipEntry(buf, skipCommentsAndExtra);\n            if (newEntry.localHeaderRelOffset >= centralDirOffset) {\n                // Ignore the entry\n                // throw new ZipException(\"Local file header offset is after central directory\");\n            } else {\n                entries.add(newEntry);\n            }\n        }\n    }\n\n    static void throwZipException(String msg, int magic) throws ZipException {\n        final String hexString = String.format(\"0x%08x\", magic);\n        throw new ZipException(msg + \" signature not found; was \" + hexString);\n    }\n\n    @Override\n    public void close() throws IOException {\n        if(file!=null){\n            file.close();\n        }\n    }\n\n    static class ZipInflaterInputStream extends InflaterInputStream {\n        private final ZipEntry entry;\n        private long bytesRead = 0;\n\n        public ZipInflaterInputStream(InputStream is, Inflater inf, int bsize, ZipEntry entry) {\n            super(is, inf, bsize);\n            this.entry = entry;\n        }\n","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-reader/src/main/java/com/googlecode/d2j/util/zip/ZipFile.java#L252-L288","documentation":"throwZipException builds the standard 'X signature not found; was 0x????????' message: an expected 4-byte record magic was absent at the position where a zip structure (local file header, central directory entry, EOCD) was being read, and the bytes actually found are reported in hex.","triggerScenarios":"Reading a central directory entry or local file header whose magic does not match (CENSIG/LOCSIG), usually because offsets are wrong or the file is corrupted/not a zip.","commonSituations":"Corrupted or hand-modified zips/APKs, wrong central directory offset after prepended data, parsing non-zip files as zips.","solutions":["Re-obtain or repair the archive (zip -FF)","Check for prepended bytes and recompute the real central directory offset","Validate the file is a zip before parsing (check EOCD and signatures)"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// verify central directory offset region begins with CENSIG before deep parsing\nraf.position(centralDirOffset);\nif (raf.getInt() != 0x02014b50) throw new IOException(\"central dir signature missing\");","typeGuard":"null","tryCatchPattern":"try { ZipFile z = new ZipFile(f); } catch (ZipException e) { log.error(e.getMessage()); /* message already contains found magic in hex */ }","preventionTips":["Validate DEX/APK integrity (checksums, signatures) before zip parsing","Avoid tools that rewrite zips in place without fixing offsets","Log the hex value from the message to identify which structure was corrupted"],"tags":["zip","signature","corrupt-file"],"backgroundTag":"checksum-mismatch","analyzedSha":"b5bda4fb4935ae8b3869b422454ae3b3896c7bc1","analyzedAt":"2026-09-08T00:44:01.258Z","contentChangedAt":"2026-09-08T00:44:01.258Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}