]> Cypherpunks repositories - gostls13.git/commit
encoding/gob: use saferio.SliceCap when decoding a slice
authorIan Lance Taylor <iant@golang.org>
Fri, 23 Sep 2022 04:17:05 +0000 (21:17 -0700)
committerGopher Robot <gobot@golang.org>
Sun, 25 Sep 2022 01:18:43 +0000 (01:18 +0000)
commita0441c7ae3dea57a0553c9ea77e184c34b7da40f
treefb5c5f7313d43568152335a5570da5665057dede
parent336ce966e439a269fe5088cc7564181c5b866b61
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>
src/debug/macho/fat.go
src/debug/macho/file.go
src/debug/pe/symbol.go
src/encoding/gob/decode.go
src/internal/saferio/io.go
src/internal/saferio/io_test.go