]> Cypherpunks.ru repositories - gostls13.git/commit
encoding/gob: prevent panic from index out of range in Decoder.typeString
authorAndy Pan <panjf2000@gmail.com>
Fri, 18 Aug 2023 05:39:57 +0000 (13:39 +0800)
committerGopher Robot <gobot@golang.org>
Sat, 19 Aug 2023 23:03:14 +0000 (23:03 +0000)
commitba626ac327f45a6d9d211fddd5b48e321fa0702a
treee19a50997936bcf46f8d85de099a39a40a8e48b3
parent7b2f81eb3b19232c1d3a60241cb92c1c50d0e4ab
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.

Fixes #62117

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>
src/encoding/gob/codec_test.go
src/encoding/gob/decode.go
src/encoding/gob/type.go