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>
diff --git a/proto/testmessages_test.go b/proto/testmessages_test.go
index 4fb0e61..4d3f898 100644
--- a/proto/testmessages_test.go
+++ b/proto/testmessages_test.go
@@ -1946,6 +1946,33 @@
}.Marshal(),
},
{
+ desc: "incorrectly terminated repeated group field",
+ decodeTo: []proto.Message{
+ (*testpb.TestAllTypes)(nil),
+ (*testeditionspb.TestAllTypes)(nil),
+ (*testpb.TestAllExtensions)(nil),
+ (*testeditionspb.TestAllExtensions)(nil),
+ },
+ wire: protopack.Message{
+ protopack.Tag{46, protopack.StartGroupType},
+ protopack.Tag{45, protopack.EndGroupType}, // should be 46
+ }.Marshal(),
+ },
+ {
+ desc: "incorrectly double-terminated repeated group field",
+ decodeTo: []proto.Message{
+ (*testpb.TestAllTypes)(nil),
+ (*testeditionspb.TestAllTypes)(nil),
+ (*testpb.TestAllExtensions)(nil),
+ (*testeditionspb.TestAllExtensions)(nil),
+ },
+ wire: protopack.Message{
+ protopack.Tag{46, protopack.StartGroupType},
+ protopack.Tag{46, protopack.EndGroupType},
+ protopack.Tag{46, protopack.EndGroupType}, // extra
+ }.Marshal(),
+ },
+ {
desc: "invalid tag varint in map item",
decodeTo: []proto.Message{
(*testpb.TestAllTypes)(nil),