uuangian / miniz

Automatically exported from code.google.com/p/miniz
0 stars 0 forks source link

Add support for zips with extra data embedded at the front #43

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  Create zip file
2.  Append zip file to arbitrary data (with zip at end)
3.  Try to read zip using miniz

What is the expected output? What do you see instead?

I expect this to work since the zip format can be appended to anything that 
still work (IE: self extracting zips are simply zips appended to binaries)

Please provide any additional information below.

If I change the line at about 3041 where you read the `cdir_ofs` to instead 
calculate it based on previous knowledge, it works.  You can even calculate the 
difference between the actual offset with the declared offset to detect how 
many bytes were inserted before the zip.

  // This is the old line that reads the offset form the file
  cdir_ofs = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_OFS_OFS);

  // If you replace it with this code, it will work for embedded zips.
  cdir_ofs = cur_file_ofs - cdir_size;

Original issue reported on code.google.com by t...@creationix.com on 17 Nov 2014 at 6:32