aboutsummaryrefslogtreecommitdiff
path: root/src/archive/zip/reader_test.go
diff options
context:
space:
mode:
authoralexander demakin <alexander.demakin@gmail.com>2015-09-10 19:43:20 +0300
committerAndrew Gerrand <adg@golang.org>2015-09-11 00:32:59 +0000
commit2b50e6b4583ee72254ca61a689ae63f9189543f7 (patch)
tree2733759ba90058e288f923cde1fe671c7e16d7a3 /src/archive/zip/reader_test.go
parent3f2baa3e60b54b5cfc45995d7d3616d4a9a509fb (diff)
downloadgo-2b50e6b4583ee72254ca61a689ae63f9189543f7.tar.gz
go-2b50e6b4583ee72254ca61a689ae63f9189543f7.zip
archive/zip: fixes unexpected EOF when reading archive
If comment of the archive contains data which looks like a zip64 directory, the comment is parsed as an actual directory header. Commit adds some additional checks similar to the checks in minizip library. Fixes #12449 Change-Id: Ia0fc950e47b9c39f77d88401b9ca30100ca7c808 Reviewed-on: https://go-review.googlesource.com/14433 Run-TryBot: Andrew Gerrand <adg@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
Diffstat (limited to 'src/archive/zip/reader_test.go')
-rw-r--r--src/archive/zip/reader_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/archive/zip/reader_test.go b/src/archive/zip/reader_test.go
index 547dd39048..8f7e8bf555 100644
--- a/src/archive/zip/reader_test.go
+++ b/src/archive/zip/reader_test.go
@@ -605,3 +605,40 @@ func TestIssue11146(t *testing.T) {
}
r.Close()
}
+
+// Verify we do not treat non-zip64 archives as zip64
+func TestIssue12449(t *testing.T) {
+ data := []byte{
+ 0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x08, 0x00,
+ 0x00, 0x00, 0x6b, 0xb4, 0xba, 0x46, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x03, 0x00, 0x18, 0x00, 0xca, 0x64,
+ 0x55, 0x75, 0x78, 0x0b, 0x00, 0x50, 0x4b, 0x05,
+ 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01,
+ 0x00, 0x49, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00,
+ 0x00, 0x31, 0x31, 0x31, 0x32, 0x32, 0x32, 0x0a,
+ 0x50, 0x4b, 0x07, 0x08, 0x1d, 0x88, 0x77, 0xb0,
+ 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+ 0x50, 0x4b, 0x01, 0x02, 0x14, 0x03, 0x14, 0x00,
+ 0x08, 0x00, 0x00, 0x00, 0x6b, 0xb4, 0xba, 0x46,
+ 0x1d, 0x88, 0x77, 0xb0, 0x07, 0x00, 0x00, 0x00,
+ 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x18, 0x00,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xa0, 0x81, 0x00, 0x00, 0x00, 0x00, 0xca, 0x64,
+ 0x55, 0x75, 0x78, 0x0b, 0x00, 0x50, 0x4b, 0x05,
+ 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01,
+ 0x00, 0x49, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00,
+ 0x00, 0x97, 0x2b, 0x49, 0x23, 0x05, 0xc5, 0x0b,
+ 0xa7, 0xd1, 0x52, 0xa2, 0x9c, 0x50, 0x4b, 0x06,
+ 0x07, 0xc8, 0x19, 0xc1, 0xaf, 0x94, 0x9c, 0x61,
+ 0x44, 0xbe, 0x94, 0x19, 0x42, 0x58, 0x12, 0xc6,
+ 0x5b, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x00, 0x01, 0x00, 0x69, 0x00, 0x00,
+ 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
+ }
+ // Read in the archive.
+ _, err := NewReader(bytes.NewReader([]byte(data)), int64(len(data)))
+ if err != nil {
+ t.Errorf("Error reading the archive: %v", err)
+ }
+}