Skip to content

Commit 102fb80

Browse files
committed
proto: add more invalid group encoding test cases
I noticed we lacked test coverage for these cases before. Change-Id: Ic407dc77f6bef8b9d496ea5dacdecbf25abc926a Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/703295 Reviewed-by: Chressie Himpel <chressie@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent b4906e6 commit 102fb80

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

proto/testmessages_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,6 +1945,33 @@ var testInvalidMessages = []testProto{
19451945
protopack.Tag{46, protopack.StartGroupType},
19461946
}.Marshal(),
19471947
},
1948+
{
1949+
desc: "incorrectly terminated repeated group field",
1950+
decodeTo: []proto.Message{
1951+
(*testpb.TestAllTypes)(nil),
1952+
(*testeditionspb.TestAllTypes)(nil),
1953+
(*testpb.TestAllExtensions)(nil),
1954+
(*testeditionspb.TestAllExtensions)(nil),
1955+
},
1956+
wire: protopack.Message{
1957+
protopack.Tag{46, protopack.StartGroupType},
1958+
protopack.Tag{45, protopack.EndGroupType}, // should be 46
1959+
}.Marshal(),
1960+
},
1961+
{
1962+
desc: "incorrectly double-terminated repeated group field",
1963+
decodeTo: []proto.Message{
1964+
(*testpb.TestAllTypes)(nil),
1965+
(*testeditionspb.TestAllTypes)(nil),
1966+
(*testpb.TestAllExtensions)(nil),
1967+
(*testeditionspb.TestAllExtensions)(nil),
1968+
},
1969+
wire: protopack.Message{
1970+
protopack.Tag{46, protopack.StartGroupType},
1971+
protopack.Tag{46, protopack.EndGroupType},
1972+
protopack.Tag{46, protopack.EndGroupType}, // extra
1973+
}.Marshal(),
1974+
},
19481975
{
19491976
desc: "invalid tag varint in map item",
19501977
decodeTo: []proto.Message{

0 commit comments

Comments
 (0)