aboutsummaryrefslogtreecommitdiff
path: root/src/debug/pe
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-09-22 21:17:05 -0700
committerGopher Robot <gobot@golang.org>2022-09-25 01:18:43 +0000
commita0441c7ae3dea57a0553c9ea77e184c34b7da40f (patch)
treefb5c5f7313d43568152335a5570da5665057dede /src/debug/pe
parent336ce966e439a269fe5088cc7564181c5b866b61 (diff)
downloadgo-a0441c7ae3dea57a0553c9ea77e184c34b7da40f.tar.xz
encoding/gob: use saferio.SliceCap when decoding a slice
This avoids allocating an overly large slice for corrupt input. Change the saferio.SliceCap function to take a pointer to the element type, so that we can handle slices of interface types. This revealed that a couple of existing calls were actually incorrect, passing the slice type rather than the element type. No test case because the problem can only happen for invalid data. Let the fuzzer find cases like this. Fixes #55338 Change-Id: I3c1724183cc275d4981379773b0b8faa01a9cbd2 Reviewed-on: https://go-review.googlesource.com/c/go/+/433296 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/debug/pe')
-rw-r--r--src/debug/pe/symbol.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/debug/pe/symbol.go b/src/debug/pe/symbol.go
index 0a5343f925..b1654f8726 100644
--- a/src/debug/pe/symbol.go
+++ b/src/debug/pe/symbol.go
@@ -59,7 +59,7 @@ func readCOFFSymbols(fh *FileHeader, r io.ReadSeeker) ([]COFFSymbol, error) {
if err != nil {
return nil, fmt.Errorf("fail to seek to symbol table: %v", err)
}
- c := saferio.SliceCap(COFFSymbol{}, uint64(fh.NumberOfSymbols))
+ c := saferio.SliceCap((*COFFSymbol)(nil), uint64(fh.NumberOfSymbols))
if c < 0 {
return nil, errors.New("too many symbols; file may be corrupt")
}