Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

archive/zip doesn't handle files generated by Java applications #1471

Closed
gopherbot opened this issue Feb 2, 2011 · 4 comments
Closed

archive/zip doesn't handle files generated by Java applications #1471

gopherbot opened this issue Feb 2, 2011 · 4 comments

Comments

@gopherbot
Copy link
Contributor

by dunhamsteve:

What steps will reproduce the problem?

1. Apply the patch in zipTest.diff
2. Place java.zip in src/pkg/archive/zip/testdata
3. Run "make test" in src/pkg/archive/zip/testdata

What is the expected output?

PASS

What do you see instead?

--- FAIL: zip.TestReader
    unexpected EOF
    unexpected EOF
    unexpected EOF
    unexpected EOF
    unexpected EOF
    unexpected EOF
    filename: copy error=unexpected EOF, want checksum error
FAIL


Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

MacOSX 10.6.5

Which revision are you using?  (hg identify)

c88661a2d028+ tip

Please provide any additional information below.

In zip files with 0x8 bit set in the Flags field, the original size, compressed size,
and CRC32 are set to 0 in the FileHeader.  The correct values are set in the end of file
directory and in a data structure that appears after the compressed data. This is
documented on wikipedia and at:
   https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip.html

These zip files occur when you use Java's ZipOutputStream to create a zip file and in
other cases where file size isn't known ahead of time. 

archive/zip correctly reads the values from the directory structure, but replaces them
with the zero'd values when the user does File.Open().  This leads to an
"unexpected EOF" error because archive/zip believes the compressed data is 0
bytes long.

Three files are attached:

   java.zip - an example of a zip file that archive/zip fails to read
      (place it in src/pkg/archive/zip/testdata )
   zipTest.diff - a diff to add a test case that reads java.zip
   zipFix.diff - a patch to fix archive/zip

I am very new to go, so please review the patch and revise as needed.

Attachments:

  1. java.zip (154 bytes)
  2. zipTest.diff (460 bytes)
  3. zipFix.diff (889 bytes)
@gopherbot
Copy link
Contributor Author

Comment 1 by dunhamsteve:

For reference, I'm also attaching the Java code that I used to generate the test file.

Attachments:

  1. MakeZip.java (494 bytes)

@rsc
Copy link
Contributor

rsc commented Feb 2, 2011

Comment 2:

Owner changed to a...@golang.org.

Status changed to Accepted.

@adg
Copy link
Contributor

adg commented Feb 14, 2011

Comment 3:

Thanks for the detailed report. A fix is on the way:
http://golang.org/cl/4183048

@adg
Copy link
Contributor

adg commented Feb 14, 2011

Comment 4:

This issue was closed by revision 858972c.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc unassigned adg Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants