The GitHub Actions job "Java CI with Ant" on 
poi.git/fix-zip-entry-read-regression has failed.
Run started by GitHub user pjfanning (triggered by pjfanning).

Head commit for run:
6480175abb119154cc61a1325aee4b31fbbaead2 / PJ Fanning 
<[email protected]>
Restore sized reads for known zip entry sizes while capping the initial 
allocation

The change in #1227 made ZipArchiveFakeEntry read every in-memory entry via
IOUtils.toByteArrayWithMaxLength, which starts from a 4KB buffer and grows by
doubling. For larger entries that produces a cascade of reallocations and
short-lived garbage arrays; with poi-integration running tests in parallel this
regressed heap usage badly enough to cause OutOfMemoryError on CI.

Restore the exactly-sized single allocation for entries with a known declared
size, while keeping #1227's protection against untrusted size fields:

- New IOUtils.toByteArray overload takes a maxInitBufferSize that caps the
  initial buffer allocation; the buffer still grows as real data arrives,
  bounded by length/maxLength. Existing overloads are unchanged.
- ZipArchiveFakeEntry uses it with a 2MB cap: entries up to 2MB (the vast
  majority) get one exactly-sized allocation, larger ones grow from a 2MB
  base, and a bogus huge declared size can force at most a 2MB eager
  allocation.
- Reads are bounded by the declared entry size again: an entry holding fewer
  bytes than declared fails with EOFException (as before #1227), and an entry
  holding more bytes than declared is now rejected with an IOException instead
  of the extra bytes being read.

The stricter size validation changes which exception 20 corrupt fuzz files in
the poi-integration corpus surface (they all declare entry sizes smaller than
the data actually present); the expected exceptions were re-derived by running
each handler against each file.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

Report URL: https://github.com/apache/poi/actions/runs/33487235034

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to