mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-01 11:58:21 +00:00
internal/encoding/json: fix crash in parsing
Fuzzer-detected crash when parsing: {"" Change-Id: I019c667f48e6a1237858b5abf7d34f43593fb3b6 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/212357 Reviewed-by: Herbie Ong <herbie@google.com>
This commit is contained in:
parent
f2427c09d6
commit
5ba0c29655
@ -102,6 +102,9 @@ func (d *Decoder) Read() (Value, error) {
|
||||
}
|
||||
d.in = d.in[n:]
|
||||
d.consume(0)
|
||||
if len(d.in) == 0 {
|
||||
return Value{}, d.newSyntaxError(`unexpected EOF, missing ":" after object name`)
|
||||
}
|
||||
if c := d.in[0]; c != ':' {
|
||||
return Value{}, d.newSyntaxError(`unexpected character %v, missing ":" after object name`, string(c))
|
||||
}
|
||||
|
@ -872,6 +872,13 @@ func TestDecoder(t *testing.T) {
|
||||
{E: `unexpected EOF`},
|
||||
},
|
||||
},
|
||||
{
|
||||
input: `{""`,
|
||||
want: []R{
|
||||
{T: json.StartObject},
|
||||
{E: `syntax error (line 1:4): unexpected EOF`},
|
||||
},
|
||||
},
|
||||
{
|
||||
input: `{"34":"89",}`,
|
||||
want: []R{
|
||||
|
Loading…
Reference in New Issue
Block a user