]> Cypherpunks repositories - gostls13.git/commit
archive/zip: tolerate compressed directories with zero uncompressed size
authorRoland Shoemaker <roland@golang.org>
Thu, 1 Dec 2022 17:02:16 +0000 (09:02 -0800)
committerGopher Robot <gobot@golang.org>
Thu, 1 Dec 2022 17:46:25 +0000 (17:46 +0000)
commit791f7580758d9e4ea2c393dbe91b5f89fa16da18
tree86253ca4cc4196b69035be4a026fa6c905f85008
parent34ab0bcc5eaf97cc0aff11cfe782e4c174d52ef0
archive/zip: tolerate compressed directories with zero uncompressed size

In CL 449955 we made reading of directories with associated file data
an error, since it is a "must not" in the zip specification. It turns
out that a number of implementations make the mistake of not setting
the correct compression method on directories (in particular the Java
jar tool does this when storing the META-INF directory). If the
compression method used is not 0 (stored) then the compressed size of
the directory can be > 0, despite the uncompressed size still being 0.

Since this mistake is not uncommon, we are forced to tolerate it. We
still fail if the recorded uncompressed size is > 0, which should be
a significantly harder mistake to make.

Change-Id: Ia732b10787f26ab937ac9cf9869ac3042efb8118
Reviewed-on: https://go-review.googlesource.com/c/go/+/454475
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
src/archive/zip/reader.go
src/archive/zip/reader_test.go