Skip to content

ZipInputStream class doesn't process correctly no compression entries with flag Bit 3 set #15

Closed

Description

@nekobul

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.

Activity

  1. self-assigned this
    on Apr 14, 2016
  2. added
    zip
    on May 16, 2016
  3. piksel commented on Oct 3, 2020

    @piksel
    Member

    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.

  4. assigned and unassigned on Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugzip

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions