-
Notifications
You must be signed in to change notification settings - Fork 18k
archive/zip: takes mtime from wrong part of infoZipUnixExtraID extra headers #23901
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
Comments
You say that, but the default ZIP archiver on OSX (at least on Sierra) continues to generate that field... |
Change https://golang.org/cl/96895 mentions this issue: |
Fix is out. Moving to 1.10.1 milestone for consideration in the point release. The new time-parsing logic was added in Go1.10, and it would be unfortunate to continue reporting the wrong timestamp. |
CL 96895 OK for Go 1.10.1 |
Change https://golang.org/cl/102782 mentions this issue: |
…tended timestamps The Info-ZIP Unix1 extra field is specified as such: >>> Value Size Description ----- ---- ----------- 0x5855 Short tag for this extra block type ("UX") TSize Short total data size for this block AcTime Long time of last access (GMT/UTC) ModTime Long time of last modification (GMT/UTC) <<< The previous handling was incorrect in that it read the AcTime field instead of the ModTime field. The test-osx.zip test unfortunately locked in the wrong behavior. Manually parsing that ZIP file shows that the encoded MS-DOS date and time are 0x4b5f and 0xa97d, which corresponds with a date of 2017-10-31 21:11:58, which matches the correct mod time (off by 1 second due to MS-DOS timestamp resolution). Fixes #23901 Change-Id: I567824c66e8316b9acd103dbecde366874a4b7ef Reviewed-on: https://go-review.googlesource.com/96895 Run-TryBot: Joe Tsai <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-on: https://go-review.googlesource.com/102782 Run-TryBot: Andrew Bonventre <[email protected]> Reviewed-by: Joe Tsai <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
Looking at src/archive/zip/reader.go from the Go 1.10 kit, I see that readDirectory() gets the modified time from the first 32 bits after an infoZipUnixExtraID's length field:
But according to file unzip60/proginfo/extrafld.txt from
https://sourceforge.net/projects/infozip/files/UnZip%206.x%20%28latest%29/UnZip%206.0/unzip60.tar.gz/download, the layout of an infoZipUnixExtraID extra is:
so the current code gets the last access time, not the last modification time.
In fact, the ModTime field in an infoZipUnixExtraID (0x5855) extra header has the same offset and size at
the ModTime field in an unixExtraID (0x000d) block, so both cases can use the same code:
zip-bug.patch.gz
This is (probably) not an important bug, because the infoZipUnixExtraID (0x5855) block has long been deprecated in favor of extTimeExtraID (0x5455) and the Unix type 2 extra block (0x7855).
The text was updated successfully, but these errors were encountered: