Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
archive/zip: CL 6811080 broke the ability to read a zip file #4393
What steps will reproduce the problem? If possible, include a link to a program on play.golang.org. 1. Download attached go and zip file. 2. Run the go program. 3. It will panic: What is the expected output? The expected output is not to panic. What do you see instead? panic: zip: not a valid zip file Which compiler are you using (5g, 6g, 8g, gccgo)? 6g Which operating system are you using? MacOS X 10.8.2 Which version are you using? (run 'go version') go version devel +f5c69f87ef34 Mon Nov 12 12:21:00 2012 +0100 Please provide any additional information below. This bug was introduced with CL 6811080: archive/zip: Fix bounds check panic for ZIP files with a truncated extra header. from dave, reviewed by adg.
That zip file contains 13 bytes of extra data, the first 4 bytes, and the following 5 bytes are consumed, leaving 4 bytes unconsumed. This was my fault, I wrote the logic assuming that you need _more_ than 4 bytes of extra data, but in this case there is a tag with a 0 length. zip: tag 30805 size 0 What program created that zip file? Can you possibly recreate the core.zip file containing only one file, so it can be used as a test file ?
Owner changed to @davecheney.
Status changed to Accepted.
Yes, sorry, the panic is in the test program. The zip file was obtained from http://www.unicode.org/Public/cldr/22/core.zip. I don't know which program they used to create it, but I do know this error does not occur with most of their zip files, so I'm not sure how easy it would be to reproduce with a smaller set.