{"record":{"id":"7e757b6c127e13b6","repo":"prestodb/presto","slug":"invalid-entry-size","errorCode":null,"errorMessage":"invalid entry size","messagePattern":"invalid entry size","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-druid/src/main/java/com/facebook/presto/druid/zip/ZipFileEntry.java","lineNumber":208,"sourceCode":"    }\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 {\n            featureSet.remove(Feature.ZIP64_SIZE);\n        }\n        this.size = size;\n    }\n\n    public long getSize()\n    {\n        return size;\n    }\n\n    public void setCompressedSize(long csize)\n    {\n        if (csize < 0) {","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-druid/src/main/java/com/facebook/presto/druid/zip/ZipFileEntry.java#L190-L226","documentation":"ZipFileEntry.setSize requires a non-negative size; negative values indicate a misparse of the 4-byte unsigned size field. Sizes above 0xffffffff are allowed but flip the entry into ZIP64_SIZE feature mode, which requires the archive to actually have ZIP64 support.","triggerScenarios":"setSize() called (via read) with size < 0 — usually a corrupt/misparsed central directory or local header size field, or caller code passing a signed int or unvalidated long.","commonSituations":"Corrupted segment zips, byte-offset bugs when reading header fields (uncompressed size at offset 24 of the CD header), or application code doing entry.setSize(intValue) where a negative int leaks through. Also: setting giant sizes unintentionally flips the entry to ZIP64 and breaks non-ZIP64 readers.","solutions":["Validate sizes are non-negative before calling setSize; mask unsigned 32-bit fields read as signed ints (size & 0xffffffffL).","Re-ingest the segment if the header bytes are corrupt (`unzip -t` to confirm).","Check custom writer code against the CentralDirectoryFileHeader field layout.","Only intentionally pass sizes > 0xffffffff when the archive is built with ZIP64 support."],"exampleFix":"// before\nentry.setSize(rawSizeInt); // may be negative from signed parse\n// after\nlong size = rawSizeInt & 0xffffffffL;\nif (size < 0) {\n    throw new IOException(\"corrupt entry size\");\n}\nentry.setSize(size);","handlingStrategy":"validation","validationCode":"long size = rawSizeInt & 0xffffffffL;\nif (size < 0) {\n    throw new IllegalArgumentException(\"negative entry size indicates corrupt header\");\n}\nentry.setSize(size);","typeGuard":null,"tryCatchPattern":"try {\n    entry.setSize(rawValue);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"invalid entry size\")) {\n        handleCorruptEntry(entryName);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Mask unsigned 32-bit size fields with 0xffffffffL before calling setSize.","Only pass sizes > 0xffffffff when the archive is ZIP64.","Validate central directory bytes against the spec layout when parsing manually."],"tags":["zip","entry-size","validation","unsigned-integer"],"backgroundTag":"invalid-zip-entry-size","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"}