RFD: Invalid CRC in ZipFile, ZipFileSystem

Alan Bateman Alan.Bateman at oracle.com
Fri Feb 24 08:21:50 UTC 2023


On 23/02/2023 16:32, Lance Andersen wrote:
> HI Eirik
>
>> On Feb 23, 2023, at 7:43 AM, Eirik Bjørsnøs <eirbjo at gmail.com> wrote:
>>
>> Hi,
>>
>> While writing various ZIP related tests, I noticed a discrepancy in 
>> the treatment of invalid CRC values:
>>
>> While ZipInputStream rejects invalid CRC values when consuming 
>> streams, ZipFile and ZipFileSystem do not.
>>
>> While this is inconsistent, it is perhaps not a bug we want to fix?
>
> I believe it is intentional.  Alan, Martin B, do you recall the history?

I think Dave Bristor or Martin looked at this at one point so you might 
have to search JBS for issues where they commented on this topic.

As a general point, the ZIP format can have redundant metadata and there 
can be cases where the CRC-32 isn't available when writing a LOC header. 
At the same time, the APIs work differently in that ZipFile opens a ZIP 
file so it has access to the CEN whereas ZipInputStream is working on a 
stream of ZIP entries and does not read the CEN.  So some 
inconsistencies in the handling is not too surprising.

-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20230224/23b3f2b8/attachment-0001.htm>


More information about the core-libs-dev mailing list