RFR: 8339711: ZipFile.Source.initCEN needlessly reads END header [v2]

Eirik Bjørsnøs eirbjo at openjdk.org
Wed Sep 25 20:33:37 UTC 2024


On Wed, 25 Sep 2024 19:44:46 GMT, Claes Redestad <redestad at openjdk.org> wrote:

> We'd be throwing an OOMError today if we soared too close to the limit (Integer.MAX_VALUE - ENDHDR - 2 and above), then throw zerror if we go beyond the limit. 

I think you might be off by one there :)

The current code incorrectly fails to reject a CEN size of `Integer.MAX_VALUE - ENDHDR - 1`, and instead cause an OOME for exceeding the implementation limit of int[]. The size `Integer.MAX_VALUE - ENDHDR - 2` is allowed, as it should.

So the existing code was off-by-one in that it allowed exactly one CEN size which was larger than the implementation limit.

Yes, I'd be surprised if this fix gets any user excited. But I think from a maintainer's point of view, it may be easier to understand code when it's stricly correct since it removes any reason to ponder why the code is almost, but not completely correct.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20905#discussion_r1775957317


More information about the core-libs-dev mailing list