in reply to Re^4: File integrity checker
in thread File integrity checker

Buried treasure! A zip file contains two copies of the file metadata, one just before the data and one at the end of the zip. Unzip uses the first one, and ziptest.pl uses the second. Neither one notices that the two copies don't match. You can modify my little script like this to make ziptest.pl complain:
while ($data =~ /PK\x01\x02/g) ... # find all file headers substr($data, $offset[1]+16, 1) ^= "\x01"; # change the crc

Replies are listed 'Best First'.
Re^6: File integrity checker
by roperl (Beadle) on Aug 29, 2017 at 19:44 UTC
    Ok that did it. Now it seems to work as expected
    # ./ziptest.pl test.zip Length Size Last Modified CRC-32 Name -------- -------- ------------------------ -------- ---- 26 14 Mon Aug 28 18:07:58 2017 75b0ca95 testfile.txt 15 9 Mon Aug 28 18:08:10 2017 32e1dbe7 testfile2.txt Member testfile2.txt CRC error: file says 32e1dbe7 computed: 32e1dbe6 CRC errors found # unzip -t test.zip Archive: test.zip testing: testfile.txt OK testing: testfile2.txt OK No errors detected in compressed data of test.zip.