zlib-ng / minizip-ng

Fork of the popular zip manipulation library found in the zlib distribution.
Other
1.25k stars 434 forks source link

unzseek64() compression_method vs. compression level #92

Closed roussec closed 7 years ago

roussec commented 7 years ago

I am not sure how unzseek() is supposed to work. Line 1897 contains the following code:

if (pfile_in_zip_read_info->compression_method != 0) return UNZ_ERRNO;

compression_method is always Z_DEFLATED (8) - althoug it seems it is sometimes used as compression level in the code? I think the idea was to check if compression level was 0 but I am not sure if this info is avaiable. How is this supposed to work?

MacGritsch commented 7 years ago

isnt it also used to store if encryption is enabled? (I dont have the code at the moment, and dont have the time to check)

roussec commented 7 years ago

Yes if encryption is enabled it also contains this flag (AES_METHOD), Z_BZIP2ED is also possible. But it is usually not the compression level which I think the above code needs to check instead of the method.

nmoinvaz commented 7 years ago

The unzip.h has comment that says it allows seeking in uncompressed data.

PKWARE APP NOTE states:

  4.4.5 compression method: (2 bytes)

    0 - The file is stored (no compression)
    1 - The file is Shrunk
    2 - The file is Reduced with compression factor 1
    3 - The file is Reduced with compression factor 2
    4 - The file is Reduced with compression factor 3
    5 - The file is Reduced with compression factor 4
    6 - The file is Imploded
    7 - Reserved for Tokenizing compression algorithm
    8 - The file is Deflated