Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions conformance/binary_json_conformance_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ void BinaryAndJsonConformanceSuite::RunSuiteImpl() {
RunUtf8ValidationTests();
}
}
RunRecursionLimitTests();
}

void BinaryAndJsonConformanceSuite::RunDelimitedFieldTests() {
Expand Down Expand Up @@ -490,6 +491,36 @@ void BinaryAndJsonConformanceSuite::RunMessageSetTests() {
);
}

void BinaryAndJsonConformanceSuite::RunRecursionLimitTests() {
{
TestAllTypesEdition2023 message;
TestAllTypesEdition2023* sub = &message;
for (int i = 0; i < 101; i++) {
sub = &(*sub->mutable_map_recursive())[0];
sub->set_optional_int32(123);
}
ExpectParseFailureForProto<TestAllTypesEdition2023>(
message.SerializeAsString(), "EnforceDepthLimit.Map", REQUIRED);
}

{
TestAllTypesProto2 proto2_msg;
auto sub = proto2_msg.mutable_message_set_correct();
for (int i = 0; i < 50; i++) {
sub = sub->MutableExtension(
TestAllTypesProto2::MessageSetCorrectExtension2::
message_set_extension)
->mutable_sub_msg();
}
sub->MutableExtension(TestAllTypesProto2::MessageSetCorrectExtension2::
message_set_extension)
->set_i(123);
ExpectParseFailureForProto<TestAllTypesProto2>(
proto2_msg.SerializeAsString(), "EnforceDepthLimit.MessageSetExtension",
REQUIRED);
}
}

template <typename MessageType>
void BinaryAndJsonConformanceSuite::ExpectParseFailureForProto(
const std::string& proto, const std::string& test_name,
Expand Down
2 changes: 2 additions & 0 deletions conformance/binary_json_conformance_suite.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class BinaryAndJsonConformanceSuite : public ConformanceTestSuite {

void RunMessageSetTests();

void RunRecursionLimitTests();

template <typename MessageType>
friend class BinaryAndJsonConformanceSuiteImpl;

Expand Down
1 change: 1 addition & 0 deletions conformance/failure_list_csharp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ Required.*.ProtobufInput.BadTag_FieldNumberTooHigh
Required.*.ProtobufInput.BadTag_FieldNumberSlightlyTooHigh # Should have failed to parse, but didn't.
Required.*.ProtobufInput.BadTag_OverlongVarint # Should have failed to parse, but didn't.
Required.*.JsonInput.AnyEmpty.*
Required.Proto2.ProtobufInput.EnforceDepthLimit.MessageSetExtension # Should have failed to parse, but didn't.
1 change: 1 addition & 0 deletions conformance/failure_list_java.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ Required.*.ProtobufInput.BadTag_OverlongVarint
# Recommended.Proto2.ProtobufInput.RejectInvalidUtf8.String.Oneof # Should have failed to parse, but didn't.
# Recommended.Proto2.ProtobufInput.RejectInvalidUtf8.String.Repeated # Should have failed to parse, but didn't.
# Recommended.Proto2.ProtobufInput.RejectInvalidUtf8.String.Singular # Should have failed to parse, but didn't.
Required.Proto2.ProtobufInput.EnforceDepthLimit.MessageSetExtension # Should have failed to parse, but didn't.
1 change: 1 addition & 0 deletions conformance/failure_list_jruby.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ Required.Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput
Required.*.ProtobufInput.BadTag_FieldNumberTooHigh # Should have failed to parse, but didn't.
Required.*.ProtobufInput.BadTag_FieldNumberSlightlyTooHigh # Should have failed to parse, but didn't.
Required.*.ProtobufInput.BadTag_OverlongVarint # Should have failed to parse, but didn't.
Required.Proto2.ProtobufInput.EnforceDepthLimit.MessageSetExtension # Should have failed to parse, but didn't.
# TODO: Uncomment once conformance tests can express failures that are not expected to be fixed.
# Recommended.Editions_Proto2.ProtobufInput.RejectInvalidUtf8.String.Oneof # Should have failed to parse, but didn't.
# Recommended.Editions_Proto2.ProtobufInput.RejectInvalidUtf8.String.Repeated # Should have failed to parse, but didn't.
Expand Down
1 change: 1 addition & 0 deletions conformance/failure_list_objc.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# JSON input or output tests are skipped (in conformance_objc.m) as mobile
# platforms don't support JSON wire format to avoid code bloat.
Required.Proto2.ProtobufInput.EnforceDepthLimit.MessageSetExtension # Should have failed to parse, but didn't.
1 change: 1 addition & 0 deletions conformance/failure_list_rust_upb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Recommended.Editions.ProtobufInput.RejectInvalidUtf8.String.Extension #
# Recommended.Proto2.ProtobufInput.RejectInvalidUtf8.String.Oneof # Should have failed to parse, but didn't.
# Recommended.Proto2.ProtobufInput.RejectInvalidUtf8.String.Repeated # Should have failed to parse, but didn't.
# Recommended.Proto2.ProtobufInput.RejectInvalidUtf8.String.Singular # Should have failed to parse, but didn't.
Required.Proto2.ProtobufInput.EnforceDepthLimit.MessageSetExtension # Should have failed to parse, but didn't.
3 changes: 3 additions & 0 deletions conformance/test_protos/test_messages_edition2023.proto
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ message TestAllTypesEdition2023 {
}
GroupLikeType groupliketype = 201;
GroupLikeType delimited_field = 202;

// recursive
map<int32, TestAllTypesEdition2023> map_recursive = 301;
}

message ForeignMessageEdition2023 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ message TestAllTypesProto2 {
}

int32 i = 9;
MessageSetCorrect sub_msg = 10;
}

message ExtensionWithOneof {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ message TestAllTypesProto2 {
}

int32 i = 9;
MessageSetCorrect sub_msg = 10;
}

message ExtensionWithOneof {
Expand Down
1 change: 1 addition & 0 deletions editions/golden/test_messages_proto2_editions.proto
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ message TestAllTypesProto2 {
}

int32 i = 9;
MessageSetCorrect sub_msg = 10;
}

message ExtensionWithOneof {
Expand Down
1 change: 1 addition & 0 deletions src/google/protobuf/test_messages_proto2.proto
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ message TestAllTypesProto2 {
optional MessageSetCorrectExtension2 message_set_extension = 4135312;
}
optional int32 i = 9;
optional MessageSetCorrect sub_msg = 10;
}

message ExtensionWithOneof {
Expand Down
1 change: 1 addition & 0 deletions upb/conformance/conformance_upb_failures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Required.*.JsonInput.AnyWithNoType.* # Fa
# Recommended.Proto2.ProtobufInput.RejectInvalidUtf8.String.Oneof # Should have failed to parse, but didn't.
# Recommended.Proto2.ProtobufInput.RejectInvalidUtf8.String.Repeated # Should have failed to parse, but didn't.
# Recommended.Proto2.ProtobufInput.RejectInvalidUtf8.String.Singular # Should have failed to parse, but didn't.
Required.Proto2.ProtobufInput.EnforceDepthLimit.MessageSetExtension # Should have failed to parse, but didn't.
Loading