The archive/zip package forbids writing data to directory files: Writing to the io.Writer returned by w.Create("dir/") fails with zip: write to directory.
However, archive/zip permits reading data from directory files. This means there are zip archives that can be read by archive/zip, but not rewritten. In addition, the zip specification doesn't permit directories to contain file data, so these archives are invalid:
Zero-byte files, directories, and other file types that contain no content MUST NOT include file data.
We should return an error when parsing a zip file that contains a directory that contains data.
Thanks to Adam Korczynski (ADA Logics) and OSS-Fuzz for the report.
The
archive/zippackage forbids writing data to directory files: Writing to theio.Writerreturned byw.Create("dir/")fails withzip: write to directory.However,
archive/zippermits reading data from directory files. This means there are zip archives that can be read byarchive/zip, but not rewritten. In addition, the zip specification doesn't permit directories to contain file data, so these archives are invalid:We should return an error when parsing a zip file that contains a directory that contains data.
Thanks to Adam Korczynski (ADA Logics) and OSS-Fuzz for the report.