]> Cypherpunks repositories - gostls13.git/commit
archive/zip: reject overflowing directorySize & directoryOffset
authorRoland Shoemaker <roland@golang.org>
Mon, 24 Apr 2023 16:31:06 +0000 (09:31 -0700)
committerGopher Robot <gobot@golang.org>
Mon, 24 Apr 2023 20:28:37 +0000 (20:28 +0000)
commita8af76284d4dadc7720b69cc3e1882865ce509e5
tree83f11e68d9db7b24640a02afdbeb153d778aa168
parent1d00dc39851cba737d3ada9a9cb4a99e525b3e9f
archive/zip: reject overflowing directorySize & directoryOffset

We added a check for incorrect baseOffset in CL 408734, but in doing so
we introduced a panic when directoryOffset overflowed a int64. The zip
spec uses uint64, but since io.SectionReader requires int64 we convert,
and possibly introduce an overflow. If offset < 0 && size-offset < 0,
SectionReader will panic when we attempt to read from it.

Since it's extremely unlikely we're ever going to process a zip file
larger than 1<<63-1 byte, just limit directory size and offset to the
max int64.

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