quazip icon indicating copy to clipboard operation
quazip copied to clipboard

Comment is not read in ZIP64 archive

Open jardik opened this issue 1 year ago • 0 comments

This is an issue of original minizip code (unzip.c), but I believe it could be fixed in QuaZip, because it is customized anyway. Issue is that in unzOpenInternal function "end of zip64 cemtral directory record" is looked for as a first thing (unz64local_SearchCentralDir64) and, if it fails, only after that end of central directory record is looked for. If zip64 end of central directory record is found, standard zip end of central directory record is ignored and comment length is set to 0 (https://github.com/stachenov/quazip/blob/98bcb48dcbc709427a930687142bbcd27d5e8594/quazip/unzip.c#L687). Due to this, the comment is never found/loaded from the archive. It also allows for loading broken/incorrect archives - archive must always contain end of central directory record (see official APPNOTE.txt, 4.3.1), and this is not checked for ZIP64 archive.

I believe correct ordering is:

  • Locate end of central directory record (and read comment from there).
  • Only after that record is found, look before the record, to see if it contains "zip64 end of central directory locator" (this has fixed size and it must immediately precede the end of central directory record).
  • After the locator is found, use it to find zip64 end of central directory record.

This way, the comment from end of central directory record can be loaded for ZIP64 archive.

jardik avatar Oct 29 '22 18:10 jardik