]> Cypherpunks.ru repositories - gostls13.git/commit
[release-branch.go1.21] encoding/gob: prevent panic from index out of range in Decode...
authorAndy Pan <panjf2000@gmail.com>
Fri, 18 Aug 2023 05:39:57 +0000 (13:39 +0800)
committerGopher Robot <gobot@golang.org>
Fri, 25 Aug 2023 20:52:06 +0000 (20:52 +0000)
commit745b81b6e6883c4fa85ade03b4f05fdbfec46b0d
treeae04307d768e63230433b4e569bfa2fb694eec9d
parent13339c75b80b906419e37596c0a1b6aeeca3f16c
[release-branch.go1.21] encoding/gob: prevent panic from index out of range in Decoder.typeString

I believe this bug is introduced by CL 460543 which optimizes the allocations
by changing the type of `idToType` from map to slice, but didn't update the
access code in `Decoder.typeString` that is safe for map but not for slice.

For #62117
Fixes #62154

Change-Id: I0f2e4cc2f34c54dada1f83458ba512a6fde6dcbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/520757
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
(cherry picked from commit ba626ac327f45a6d9d211fddd5b48e321fa0702a)
Reviewed-on: https://go-review.googlesource.com/c/go/+/521156
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
src/encoding/gob/codec_test.go
src/encoding/gob/decode.go
src/encoding/gob/type.go