You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ZipInputStream class doesn't process correctly no compression entries with flag Bit 3 set #15
The PKZIP documentation here states for general purpose flag Bit 3:
"If this bit is set, the fields crc-32, compressed size and uncompressed size are set to zero in the local header. The correct values are put in the data descriptor immediately following the compressed data. (Note: PKZIP version 2.04g for DOS only recognizes this bit for method 8 compression, newer versions of PKZIP recognize this bit for any compression method.)".
The CRC, compressed and uncompressed size will be 0 and the extraction fails.
I don't think this could ever be supported by ZipInputStream. How many bytes would you read before reading the length? It's a bit of a catch-22, you need to know the length of the "compressed" data to know where to read the length of said data.
For other compression schemes, the end of the compressed stream can be indicated by the contents, but that's not possible for uncompressed data. So, for uncompressed, we need to rely on the central header, which is not used in ZipInputStream (since it would require seeking). The occurrence of zip entries with no encryption but using descriptors should be really rare, both since it's actually not supported (I think what APPNOTE.TXT:4.4.4 refers to here is literally compression methods, and not uncompressed), and because the size is generally known before writing the data (since it's just the size of the input source).
However, this should have it's own exception that explains this better.
Activity
piksel commentedon Oct 3, 2020
I don't think this could ever be supported by ZipInputStream. How many bytes would you read before reading the length? It's a bit of a catch-22, you need to know the length of the "compressed" data to know where to read the length of said data.
For other compression schemes, the end of the compressed stream can be indicated by the contents, but that's not possible for uncompressed data. So, for uncompressed, we need to rely on the central header, which is not used in ZipInputStream (since it would require seeking). The occurrence of zip entries with no encryption but using descriptors should be really rare, both since it's actually not supported (I think what APPNOTE.TXT:4.4.4 refers to here is literally compression methods, and not uncompressed), and because the size is generally known before writing the data (since it's just the size of the input source).
However, this should have it's own exception that explains this better.