]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.16] archive/zip: prevent preallocation check from overflowing
authorRoland Shoemaker <roland@golang.org>
Wed, 18 Aug 2021 18:49:29 +0000 (11:49 -0700)
committerCherry Mui <cherryyz@google.com>
Wed, 1 Sep 2021 16:41:45 +0000 (16:41 +0000)
commit6c480017ae600b2c90a264a922e041df04dfa785
treee7b5190caa48933cfa49a50d544569325888a606
parent0d530843be0021aa56771c2f922e952beb190d97
[release-branch.go1.16] archive/zip: prevent preallocation check from overflowing

If the indicated directory size in the archive header is so large that
subtracting it from the archive size overflows a uint64, the check that
the indicated number of files in the archive can be effectively
bypassed. Prevent this from happening by checking that the indicated
directory size is less than the size of the archive.

Thanks to the OSS-Fuzz project for discovering this issue and to
Emmanuel Odeke for reporting it.

Fixes #47985
Updates #47801
Fixes CVE-2021-39293

Change-Id: Ifade26b98a40f3b37398ca86bd5252d12394dd24
Reviewed-on: https://go-review.googlesource.com/c/go/+/343434
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
(cherry picked from commit bacbc33439b124ffd7392c91a5f5d96eca8c0c0b)
Reviewed-on: https://go-review.googlesource.com/c/go/+/345409
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Cherry Mui <cherryyz@google.com>
src/archive/zip/reader.go
src/archive/zip/reader_test.go