aboutsummaryrefslogtreecommitdiff
path: root/src/archive/zip/reader_test.go
diff options
context:
space:
mode:
authorHeschi Kreinick <heschi@google.com>2021-10-07 19:02:56 -0400
committerHeschi Kreinick <heschi@google.com>2021-10-07 19:02:56 -0400
commit35d5cd0dcfb9d06064ec37da1621d24676454058 (patch)
tree5319064d4c2970a6d3be069b9c2a0e273f0f14dd /src/archive/zip/reader_test.go
parent0d02a0d966b6d307ac33e3df3687948b74408569 (diff)
parentc580180744e60d6c84fc0b59d634fcff01290780 (diff)
downloadgo-35d5cd0dcfb9d06064ec37da1621d24676454058.tar.gz
go-35d5cd0dcfb9d06064ec37da1621d24676454058.zip
[dev.boringcrypto.go1.16] all: merge go1.16.9 into dev.boringcrypto.go1.16
Change-Id: Ic26e9802fe13c491fcc26f34b8847779ac43cfe2
Diffstat (limited to 'src/archive/zip/reader_test.go')
-rw-r--r--src/archive/zip/reader_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/archive/zip/reader_test.go b/src/archive/zip/reader_test.go
index 471be27bb1..99f13345d8 100644
--- a/src/archive/zip/reader_test.go
+++ b/src/archive/zip/reader_test.go
@@ -1225,3 +1225,21 @@ func TestCVE202133196(t *testing.T) {
t.Errorf("Archive has unexpected number of files, got %d, want 5", len(r.File))
}
}
+
+func TestCVE202139293(t *testing.T) {
+ // directory size is so large, that the check in Reader.init
+ // overflows when subtracting from the archive size, causing
+ // the pre-allocation check to be bypassed.
+ data := []byte{
+ 0x50, 0x4b, 0x06, 0x06, 0x05, 0x06, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x4b,
+ 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x4b,
+ 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
+ 0xff, 0x50, 0xfe, 0x00, 0xff, 0x00, 0x3a, 0x00, 0x00, 0x00, 0xff,
+ }
+ _, err := NewReader(bytes.NewReader(data), int64(len(data)))
+ if err != ErrFormat {
+ t.Fatalf("unexpected error, got: %v, want: %v", err, ErrFormat)
+ }
+}