On Mon, 30 Nov 2026 23:33:44 GMT, Jean-Noël Rouvignac <[email protected]> wrote:

>> ZipInputStream.readLOC() calls ZipEntry.setExtra0() without translating 
>> IllegalArgumentException into ZipException. setExtra0() rejects a local 
>> entry when the combined central-header size, entry name, and extra field 
>> exceeds 65535 bytes.
>> 
>> For example, an empty entry name with an extra-field length of 65490 causes 
>> IllegalArgumentException from getNextEntry(). The same input also causes the 
>> JarInputStream constructor to throw the unchecked exception instead of its 
>> documented IOException.
>> 
>> Malformed local headers should be rejected with ZipException. The exception 
>> translation should cover both entry creation and extra-field processing so 
>> that all invalid LOC length combinations follow the public IOException 
>> contract.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> src/java.base/share/classes/java/util/zip/ZipInputStream.java line 560:
> 
>> 558:                         e.csize == ZIP64_MAGICVAL || e.size == 
>> ZIP64_MAGICVAL, true);
>> 559:             } catch (IllegalArgumentException ex) {
>> 560:                 throw (ZipException) new ZipException(
> 
> This cast seems superfluous and can be removed?

On first sight, yes :) I've been confused about similar casts in this code in 
the past. However, that cast isn't for the `new ZipException(...)` call, 
instead it's for the `initCause(...)` call which returns a `Throwable`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/34121#discussion_r4747939878

Reply via email to