Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

v0.2.0

Compare
Choose a tag to compare
@ericchiang ericchiang released this 05 Jan 23:13
· 25 commits to main since this release
Fix additional corruption with zips created on linux containing empty…

… directories

This is similar to https://github.com/google/log4jscanner/pull/36.

Go's zip library has some "interesting" behavior where if you call
zipWriter.CreateHeader with a file header that already contains
extra metadata encoding the last modified time for an empty directory,
it will append the current last modified time to the existing one
stored in the `Extra` field. This leads to corruption similar to #36
where MacOS will refuse to open the zip and `zipinfo -v` will show a
"There are an extra -xxx bytes preceding this file" warning.

I think the Go's library solution to this would be to use CreateRaw,
but we actually do want most of the logic that CreateHeader implements
(see #36 where we switched to CreateHeader). So instead, I just clear
the Extra field in the file header when copying over directories. This
means that directories will have their last modified time reset to the
current date. This is somewhat incorrect, but seems to me like a
reasonable compromise to me.