]> Cypherpunks repositories - gostls13.git/commit
encoding/json: always verify we can get a field's value
authorDaniel Martí <mvdan@mvdan.cc>
Thu, 11 Oct 2018 13:43:47 +0000 (14:43 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 16 Oct 2018 14:02:52 +0000 (14:02 +0000)
commit4b36e129f865f802eb87f7aa2b25e3297c5d8cfd
treef2eb7fea3a5ded1148941a9dbfc7c6d22e6b36ea
parent5eff6bfdbc837f8099503566ffe52e5174e804a7
encoding/json: always verify we can get a field's value

Calling .Interface on a struct field's reflect.Value isn't always safe.
For example, if that field is an unexported anonymous struct.

We only descended into this branch if the struct type had any methods,
so this bug had gone unnoticed for a few release cycles.

Add the check, and add a simple test case.

Fixes #28145.

Change-Id: I02f7e0ab9a4a0c18a5e2164211922fe9c3d30f64
Reviewed-on: https://go-review.googlesource.com/c/141537
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/encoding/json/decode.go
src/encoding/json/decode_test.go