mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-17 01:12:51 +00:00
internal/impl: fix validator bytes field length decoding
Missing a bounds check on the first byte. Change-Id: I089fa8dcc1a14d11faca1acba758b6b811b16ac4 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/216957 Reviewed-by: Joe Tsai <joetsai@google.com>
This commit is contained in:
parent
c70f5d59d1
commit
6f2977906d
@ -414,7 +414,7 @@ State:
|
||||
continue State
|
||||
case wire.BytesType:
|
||||
var size uint64
|
||||
if b[0] < 0x80 {
|
||||
if len(b) >= 1 && b[0] < 0x80 {
|
||||
size = uint64(b[0])
|
||||
b = b[1:]
|
||||
} else if len(b) >= 2 && b[1] < 128 {
|
||||
|
@ -2068,4 +2068,24 @@ var testInvalidMessages = []testProto{
|
||||
}},
|
||||
}.Marshal(),
|
||||
},
|
||||
{
|
||||
desc: "varint field overruns message",
|
||||
decodeTo: []proto.Message{
|
||||
(*testpb.TestAllTypes)(nil),
|
||||
(*testpb.TestAllExtensions)(nil),
|
||||
},
|
||||
wire: pack.Message{
|
||||
pack.Tag{1, pack.VarintType},
|
||||
}.Marshal(),
|
||||
},
|
||||
{
|
||||
desc: "bytes field lacks size",
|
||||
decodeTo: []proto.Message{
|
||||
(*testpb.TestAllTypes)(nil),
|
||||
(*testpb.TestAllExtensions)(nil),
|
||||
},
|
||||
wire: pack.Message{
|
||||
pack.Tag{18, pack.BytesType},
|
||||
}.Marshal(),
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user