{"record":{"id":"211d6af6db82d16b","repo":"prestodb/presto","slug":"invalid-entry-crc-32","errorCode":null,"errorMessage":"invalid entry crc-32","messagePattern":"invalid entry crc-32","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-druid/src/main/java/com/facebook/presto/druid/zip/ZipFileEntry.java","lineNumber":195,"sourceCode":"    public String getName()\n    {\n        return name;\n    }\n\n    public void setTime(long time)\n    {\n        this.time = time;\n    }\n\n    public long getTime()\n    {\n        return time;\n    }\n\n    public void setCrc(long crc)\n    {\n        if (crc < 0 || crc > 0xffffffffL) {\n            throw new IllegalArgumentException(\"invalid entry crc-32\");\n        }\n        this.crc = crc;\n    }\n\n    public long getCrc()\n    {\n        return crc;\n    }\n\n    public void setSize(long size)\n    {\n        if (size < 0) {\n            throw new IllegalArgumentException(\"invalid entry size\");\n        }\n        if (size > 0xffffffffL) {\n            featureSet.add(Feature.ZIP64_SIZE);\n        }\n        else {","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-druid/src/main/java/com/facebook/presto/druid/zip/ZipFileEntry.java#L177-L213","documentation":"ZipFileEntry.setCrc validates that a CRC-32 value fits in the unsigned 32-bit range [0, 0xffffffff] because the ZIP format stores CRC-32 in a 4-byte field. A negative or oversized value cannot come from well-formed central directory bytes and indicates a parsing or computation bug, so it throws IllegalArgumentException.","triggerScenarios":"setCrc() called (via read) with a value < 0 or > 0xffffffffL — typically from misparsed fixed-size data (wrong offsets/corrupt header) or code that computes/stores the CRC incorrectly (e.g., signed int interpreted as negative).","commonSituations":"Corrupt central directory entries, byte-offset bugs when reading fixed-size data, or application code that does `int crc = ...; entry.setCrc(crc)` where a negative signed int leaks through instead of being masked with 0xffffffffL.","solutions":["Mask computed CRCs to unsigned 32-bit before storing: entry.setCrc(crcValue & 0xffffffffL).","Verify the zip entry header bytes are not corrupt; re-ingest the segment if so.","Check any custom writer offsets against the CentralDirectoryFileHeader layout (CRC at offset 16).","Run `unzip -t` on the archive to confirm the stored CRCs are valid."],"exampleFix":"// before\nentry.setCrc(crc32.getValue()); // if crc32.getValue() typed as int/negative long path\n// after\nlong crc = crc32.getValue() & 0xffffffffL;\nentry.setCrc(crc);","handlingStrategy":"validation","validationCode":"long crc = crc32.getValue() & 0xffffffffL;\nif (crc < 0 || crc > 0xffffffffL) {\n    throw new IllegalArgumentException(\"CRC out of unsigned 32-bit range\");\n}\nentry.setCrc(crc);","typeGuard":null,"tryCatchPattern":"try {\n    entry.setCrc(rawValue);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"invalid entry crc-32\")) {\n        entry.setCrc(rawValue & 0xffffffffL);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Always mask CRC values with 0xffffffffL before storing in zip entries.","Never assign CRC fields from signed ints without masking.","Validate entry headers when parsing custom zip formats."],"tags":["zip","crc32","validation","unsigned-integer"],"backgroundTag":"invalid-crc-value","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}