prestodb/presto · error · IllegalArgumentException

invalid entry size

Error message

invalid entry size

What it means

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.

Source

Thrown at presto-druid/src/main/java/com/facebook/presto/druid/zip/ZipFileEntry.java:208

    }

    public void setCrc(long crc)
    {
        if (crc < 0 || crc > 0xffffffffL) {
            throw new IllegalArgumentException("invalid entry crc-32");
        }
        this.crc = crc;
    }

    public long getCrc()
    {
        return crc;
    }

    public void setSize(long size)
    {
        if (size < 0) {
            throw new IllegalArgumentException("invalid entry size");
        }
        if (size > 0xffffffffL) {
            featureSet.add(Feature.ZIP64_SIZE);
        }
        else {
            featureSet.remove(Feature.ZIP64_SIZE);
        }
        this.size = size;
    }

    public long getSize()
    {
        return size;
    }

    public void setCompressedSize(long csize)
    {
        if (csize < 0) {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Validate sizes are non-negative before calling setSize; mask unsigned 32-bit fields read as signed ints (size & 0xffffffffL).
  2. Re-ingest the segment if the header bytes are corrupt (`unzip -t` to confirm).
  3. Check custom writer code against the CentralDirectoryFileHeader field layout.
  4. Only intentionally pass sizes > 0xffffffff when the archive is built with ZIP64 support.

Example fix

// before
entry.setSize(rawSizeInt); // may be negative from signed parse
// after
long size = rawSizeInt & 0xffffffffL;
if (size < 0) {
    throw new IOException("corrupt entry size");
}
entry.setSize(size);
Defensive patterns

Strategy: validation

Validate before calling

long size = rawSizeInt & 0xffffffffL;
if (size < 0) {
    throw new IllegalArgumentException("negative entry size indicates corrupt header");
}
entry.setSize(size);

Try / catch

try {
    entry.setSize(rawValue);
} catch (IllegalArgumentException e) {
    if (e.getMessage().equals("invalid entry size")) {
        handleCorruptEntry(entryName);
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/7e757b6c127e13b6. Report an issue: GitHub.