{"record":{"id":"3bc68e68f6fd9312","repo":"Tencent/tinker","slug":"size-mismatch-on-inflated-file-bytesread-vs","errorCode":null,"errorMessage":"Size mismatch on inflated file: ${bytesRead} vs ${entry.size}","messagePattern":"Size mismatch on inflated file: (.+?) vs (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"info","filePath":"third-party/tinker-ziputils/src/main/java/com/tencent/tinker/ziputils/ziputil/TinkerZipFile.java","lineNumber":586,"sourceCode":"    /** @hide */\n    /*public static class ZipInflaterInputStream extends InflaterInputStream {\n        private final ZipEntry entry;\n        private long bytesRead = 0;\n        public ZipInflaterInputStream(InputStream is, Inflater inf, int bsize, ZipEntry entry) {\n            super(is, inf, bsize);\n            this.entry = entry;\n        }\n        @Override public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException {\n            final int i;\n            try {\n                i = super.read(buffer, byteOffset, byteCount);\n            } catch (IOException e) {\n                throw new IOException(\"Error reading data for \" + entry.getName() + \" near offset \"\n                        + bytesRead, e);\n            }\n            if (i == -1) {\n                if (entry.size != bytesRead) {\n                    throw new IOException(\"Size mismatch on inflated file: \" + bytesRead + \" vs \"\n                            + entry.size);\n                }\n            } else {\n                bytesRead += i;\n            }\n            return i;\n        }\n        @Override public int available() throws IOException {\n            if (closed) {\n                // Our superclass will throw an exception, but there's a jtreg test that\n                // explicitly checks that the InputStream returned from ZipFile.getInputStream\n                // returns 0 even when closed.\n                return 0;\n            }\n            return super.available() == 0 ? 0 : (int) (entry.getSize() - bytesRead);\n        }\n    }*/\n}","sourceCodeStart":568,"sourceCodeEnd":604,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/third-party/tinker-ziputils/src/main/java/com/tencent/tinker/ziputils/ziputil/TinkerZipFile.java#L568-L604","documentation":"IOException('Size mismatch on inflated file: <bytesRead> vs <entry.size>') also lives inside the commented-out ZipInflaterInputStream class (TinkerZipFile.java:569 onward) and is unreachable in this fork. Its original purpose: when the inflater reports EOF, compare the number of bytes actually inflated (bytesRead) with the uncompressed size recorded in the entry's metadata (entry.size); a mismatch means either the deflate stream or the size field is wrong. In the live code of this repository it can never be thrown.","triggerScenarios":"In builds where the class is active: reading an entry whose DEFLATE stream ends at a different byte count than the central directory's uncompressed-size field — truncated data, an entry recompressed without updating sizes, or a tampered size field. In this repository: unreachable.","commonSituations":"Hot-patch/zip-flushing tools that rewrite entry data but keep stale size metadata; partially downloaded archives; auditing logs from a build derived from AOSP's zip implementation.","solutions":["If hit on an AOSP-derived build: verify whether the deflate stream or the size field is wrong (inflate fully with an independent tool); usually the archive must be regenerated.","Ensure any tool that rewrites entry contents also updates size/crc in the central directory and local headers.","In this repository, no handling needed — dead code."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// only relevant on builds where ZipInflaterInputStream is enabled (not this fork)\ntry {\n    readFully(in, expectedSize);\n} catch (IOException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Size mismatch on inflated file\")) {\n        // metadata disagrees with actual inflated bytes — archive is inconsistent\n        throw new IOException(\"Entry size metadata does not match data; rebuild archive\", e);\n    }\n    throw e;\n}","preventionTips":["Any tool that rewrites entry data must also update size and CRC in both headers and the CD.","Verify size fields against actual inflated output when generating archives.","In this fork, no handling needed — dead code."],"tags":["zip","dead-code","size-mismatch","tinker"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}