Yutaka-Sawada / MultiPar

Parchive tool
998 stars 44 forks source link

Potential problems with Instructions on website for adding par2 record to the end of a ZIP file. #44

Closed dgonyier closed 3 years ago

dgonyier commented 3 years ago

Hi,

I like the idea of appending PAR2 data to the end of a ZIP for integrity verification as per the instructions on @Yutaka-Sawada 's web page: http://hp.vector.co.jp/authors/VA021385/record.htm

However the method described for ZIP files has some issues.

  1. If there is an archive comment added to the ZIP file, copying the last 22 bytes is not enough.
  2. The EOC for ZIP64 (EOCD64) is different from classic ZIP files, plus it also has the appended archive comment issue as well.

For both cases, it seems the safest option is to search backwards from the end of the ZIP/ZIP64 file for End of central directory signature = 0x06054b50 or End of central directory signature = 0x06064b50 (ZIP64) and start the binary copy from the beginning of that signature. Should not have to scan many bytes to find it, unless the archive comment text is very large for some reason.

For reference: https://en.wikipedia.org/wiki/ZIP_(file_format)

Please consider updating the instructions on this web page for better ZIP file compatibility. Unfortunately it makes the process more complicated, but it makes the resulting ZIP+PAR2DATA file more compatible with zip/unzip tools.

Thanks.

Yutaka-Sawada commented 3 years ago

However the method described for ZIP files has some issues.

Thank you for the notice. I see the problem. Because most ZIP archivers don't write comment on ZIP file, I ignored the feature. When I wrote the manual ago, new ZIP64 format was strange. Then, I didn't mention those issues.

Please consider updating the instructions on this web page for better ZIP file compatibility.

I updated the web-page. I'm not good at English language so much. If you see something wrong or odd words, please correct me.

Yutaka-Sawada commented 3 years ago

I updated par2j to support ZIP64 format, too. Then MultiPar can treat ZIP archive with 2 GB over file size. I tested ZIP file of 5 GB size on Windows 10 and 7-Zip.

I put the sample (par2j_sample_2021-09-03.zip) in "MultiPar_sample" folder on OneDrive. If you are lazy to modify ZIP file manually with a binary edior, you may try my par2j's appending recovery record feature.

dgonyier commented 3 years ago

However the method described for ZIP files has some issues.

Thank you for the notice. I see the problem. Because most ZIP archivers don't write comment on ZIP file, I ignored the feature. When I wrote the manual ago, new ZIP64 format was strange. Then, I didn't mention those issues.

Please consider updating the instructions on this web page for better ZIP file compatibility.

I updated the web-page. I'm not good at English language so much. If you see something wrong or odd words, please correct me.

Here are my suggested edits:

Step 4 is required only for ZIP archive:

There is "end of central directory record" (starting with a byte sequence
of: 0x06054b50) at the end of the ZIP file. With binary editor, copy the
section (22-bytes or more) and append it to the end of recovery
data. The construction of the file is like below;

Original ZIP archive file   Appended PAR2 recovery data     End of central directory record.

When the ZIP file is ZIP64 format, copy "zip64 end of central directory record" from the end of the ZIP file
(starting with a different byte sequence instead: 0x06064b50).

Original ZIP64 archive file Appended PAR2 recovery data     Zip64 end of central directory record.
dgonyier commented 3 years ago

I updated par2j to support ZIP64 format, too. Then MultiPar can treat ZIP archive with 2 GB over file size. I tested ZIP file of 5 GB size on Windows 10 and 7-Zip.

I put the sample (par2j_sample_2021-09-03.zip) in "MultiPar_sample" folder on OneDrive. If you are lazy to modify ZIP file manually with a binary edior, you may try my par2j's appending recovery record feature.

I will try this sample par2j out on few ZIP files and let you know if it works.

Yutaka-Sawada commented 3 years ago

Thank you for reply. I read APPNOTE from pkware to know ZIP64 format.

The order of sections of ZIP64 format is like below; [central directory header n] [zip64 end of central directory record] [zip64 end of central directory locator] [end of central directory record]

From my test, the last 3 sections are required for Windows OS. While 7-Zip File Manager seems to search those sections automatically, Windows Explorer doesn't find them. So, I need to put the "zip64 end of central directory record" and following sections. I don't know why Windows Explorer requires other sections in addition to "zip64 end of central directory record". Maybe it checks the correctness of file format. I updated the web-page.