diff options
| author | Roland Shoemaker <roland@golang.org> | 2022-07-15 10:43:44 -0700 |
|---|---|---|
| committer | Roland Shoemaker <roland@golang.org> | 2022-07-27 18:31:51 +0000 |
| commit | 055113ef364337607e3e72ed7d48df67fde6fc66 (patch) | |
| tree | 7d2c3cb068cabbeece31d6782b7153693e2570f4 /src/math/big/floatmarsh_test.go | |
| parent | 424814615491c604e6a0945f33e5a7b779dc2be5 (diff) | |
| download | go-055113ef364337607e3e72ed7d48df67fde6fc66.tar.xz | |
math/big: check buffer lengths in GobDecode
In Float.GobDecode and Rat.GobDecode, check buffer sizes before
indexing slices.
Fixes #53871
Change-Id: I1b652c32c2bc7a0e8aa7620f7be9b2740c568b0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/417774
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tatiana Bradley <tatiana@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Diffstat (limited to 'src/math/big/floatmarsh_test.go')
| -rw-r--r-- | src/math/big/floatmarsh_test.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/math/big/floatmarsh_test.go b/src/math/big/floatmarsh_test.go index c056d78b80..401f45a51f 100644 --- a/src/math/big/floatmarsh_test.go +++ b/src/math/big/floatmarsh_test.go @@ -137,3 +137,15 @@ func TestFloatJSONEncoding(t *testing.T) { } } } + +func TestFloatGobDecodeShortBuffer(t *testing.T) { + for _, tc := range [][]byte{ + []byte{0x1, 0x0, 0x0, 0x0}, + []byte{0x1, 0xfa, 0x0, 0x0, 0x0, 0x0}, + } { + err := NewFloat(0).GobDecode(tc) + if err == nil { + t.Error("expected GobDecode to return error for malformed input") + } + } +} |
