]> Cypherpunks repositories - gostls13.git/commit
debug/macho, internal/saferio: limit slice allocation
authorIan Lance Taylor <iant@golang.org>
Thu, 23 Jun 2022 22:57:10 +0000 (15:57 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 17 Aug 2022 03:08:49 +0000 (03:08 +0000)
commit7adfa82726280371bb4dfc710dc4168dfd9de703
treec2f66cbaf63ea52832c65869f9063bc030548f4a
parent71424806fa76d5b5d1b2492741d2564664af136c
debug/macho, internal/saferio: limit slice allocation

Don't allocate slices that are too large; choose a smaller capacity
and build the slice using append. Use this in debug/macho to avoid
over-allocating if a fat header is incorrect.

No debug/macho test case because the problem can only happen for
invalid data. Let the fuzzer find cases like this.

For #47653
Fixes #52523

Change-Id: I372c9cdbdda8626a3225e79d713650beb350ebc7
Reviewed-on: https://go-review.googlesource.com/c/go/+/413874
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
src/debug/macho/fat.go
src/go/build/deps_test.go
src/internal/saferio/io.go
src/internal/saferio/io_test.go