From 2177a2e7401859434297ec574e9015d30cf84d42 Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Thu, 7 Nov 2024 20:40:58 -0800 Subject: [PATCH] Add a conformance test for unmatched start group tag. PiperOrigin-RevId: 694345563 --- conformance/binary_json_conformance_suite.cc | 21 +++++++++++++++++-- conformance/binary_json_conformance_suite.h | 2 +- .../Reflection/FeatureSetDescriptor.g.cs | 17 --------------- 3 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs diff --git a/conformance/binary_json_conformance_suite.cc b/conformance/binary_json_conformance_suite.cc index 1399611748..15de2a578d 100644 --- a/conformance/binary_json_conformance_suite.cc +++ b/conformance/binary_json_conformance_suite.cc @@ -1367,7 +1367,7 @@ void BinaryAndJsonConformanceSuiteImpl::TestIllegalTags() { } template -void BinaryAndJsonConformanceSuiteImpl::TestUnmatchedEndGroup() { +void BinaryAndJsonConformanceSuiteImpl::TestUnmatchedGroup() { ExpectParseFailureForProto(tag(201, WireFormatLite::WIRETYPE_END_GROUP), "UnmatchedEndGroup", REQUIRED); ExpectParseFailureForProto(tag(1234, WireFormatLite::WIRETYPE_END_GROUP), @@ -1384,6 +1384,23 @@ void BinaryAndJsonConformanceSuiteImpl::TestUnmatchedEndGroup() { absl::StrCat(tag(1, WireFormatLite::WIRETYPE_END_GROUP), len(2, "hello world")), "UnmatchedEndGroupWithData", REQUIRED); + + ExpectParseFailureForProto(tag(201, WireFormatLite::WIRETYPE_START_GROUP), + "UnmatchedStartGroup", REQUIRED); + ExpectParseFailureForProto(tag(1234, WireFormatLite::WIRETYPE_START_GROUP), + "UnmatchedStartGroupUnknown", REQUIRED); + ExpectParseFailureForProto(tag(1, WireFormatLite::WIRETYPE_START_GROUP), + "UnmatchedStartGroupWrongType", REQUIRED); + ExpectParseFailureForProto( + len(18, tag(1234, WireFormatLite::WIRETYPE_START_GROUP)), + "UnmatchedStartGroupNestedLen", REQUIRED); + ExpectParseFailureForProto( + group(201, tag(202, WireFormatLite::WIRETYPE_START_GROUP)), + "UnmatchedStartGroupNested", REQUIRED); + ExpectParseFailureForProto( + absl::StrCat(tag(1, WireFormatLite::WIRETYPE_START_GROUP), + len(2, "hello world")), + "UnmatchedStartGroupWithData", REQUIRED); } template @@ -1573,7 +1590,7 @@ void BinaryAndJsonConformanceSuiteImpl::RunAllTests() { } TestIllegalTags(); - TestUnmatchedEndGroup(); + TestUnmatchedGroup(); TestUnknownWireType(); int64_t kInt64Min = -9223372036854775808ULL; diff --git a/conformance/binary_json_conformance_suite.h b/conformance/binary_json_conformance_suite.h index 3166eb4897..9c990557d7 100644 --- a/conformance/binary_json_conformance_suite.h +++ b/conformance/binary_json_conformance_suite.h @@ -143,7 +143,7 @@ class BinaryAndJsonConformanceSuiteImpl { ConformanceLevel level); void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type); void TestIllegalTags(); - void TestUnmatchedEndGroup(); + void TestUnmatchedGroup(); void TestUnknownWireType(); void TestOneofMessage(); void TestUnknownMessage(); diff --git a/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs b/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs deleted file mode 100644 index 208ce1fcb6..0000000000 --- a/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs +++ /dev/null @@ -1,17 +0,0 @@ -#region Copyright notice and license -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd -#endregion - -namespace Google.Protobuf.Reflection; - -internal sealed partial class FeatureSetDescriptor -{ - // Canonical serialized form of the edition defaults, generated by embed_edition_defaults. - private const string DefaultsBase64 = - "ChMYhAciACoMCAEQAhgCIAMoATACChMY5wciACoMCAIQARgBIAIoATABChMY6AciDAgBEAEYASACKAEwASoAIOYHKOgH"; -}