Skip to content
Merged
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
35 changes: 35 additions & 0 deletions conformance/binary_json_conformance_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,41 @@ void BinaryAndJsonConformanceSuiteImpl<MessageType>::TestIllegalTags() {
name.back() += i;
ExpectParseFailureForProto(nullfield[i], name, REQUIRED);
}

// Reused for a few cases: this is a single byte tag for a field number 1
// varint but where the byte has the continuation bit set, so that we can
// easily construct longer tags.
std::string tag_with_continuation_bit =
tag(1, WireFormatLite::WIRETYPE_VARINT);
assert(tag_with_continuation_bit.size() == 1);
tag_with_continuation_bit[0] |= 0b10000000;

// A varint where field number is far out of range of
// maximum legal field number. The lower 5 bytes of the varint do look like a
// well-formed tag for field number 1.
ExpectParseFailureForProto(
absl::StrCat(tag_with_continuation_bit, "\x80\x80\x80\x80\x80\x0F",
varint(1234)),
"BadTag_FieldNumberTooHigh", REQUIRED);

// A 5-byte tag varint where the value is above UINT32_MAX (bit 35 is set)
ExpectParseFailureForProto(
absl::StrCat(tag_with_continuation_bit, "\x80\x80\x80\x40", varint(1234)),
"BadTag_FieldNumberSlightlyTooHigh", REQUIRED);

// A tag where the varint is more than 5 bytes but only because it is an
// overlong varint, so the decoded value is still below UINT32_MAX.
ExpectParseFailureForProto(
absl::StrCat(tag_with_continuation_bit, "\x80\x80\x80\x80\x80\x80\x80",
std::string("\0", 1), varint(1234)),
"BadTag_OverlongVarint", REQUIRED);

// An overlong varint that is even more than 10 bytes.
ExpectParseFailureForProto(
absl::StrCat(tag_with_continuation_bit,
"\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80",
std::string("\0", 1), varint(1234)),
"BadTag_VarintMoreThanTenBytes", REQUIRED);
}

template <typename MessageType>
Expand Down
2 changes: 1 addition & 1 deletion conformance/failure_list_cpp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Recommended.*.FieldMaskTooManyUnderscore.JsonOutput
Recommended.*.JsonInput.FieldMaskInvalidCharacter # Should have failed to parse, but didn't.
Required.*.JsonInput.SingleValueForRepeatedFieldInt32 # Should have failed to parse, but didn't.
Required.*.JsonInput.SingleValueForRepeatedFieldMessage # Should have failed to parse, but didn't.

Required.*.ProtobufInput.BadTag_FieldNumberSlightlyTooHigh # Should have failed to parse, but didn't.
4 changes: 4 additions & 0 deletions conformance/failure_list_csharp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ Recommended.Editions_Proto3.ValueRejectNanNumberValue.JsonOutput
Required.Editions_Proto2.ProtobufInput.UnknownOrdering.ProtobufOutput
Required.Editions_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.

3 changes: 3 additions & 0 deletions conformance/failure_list_java.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ Required.*.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
Required.*.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt # Should have failed to parse, but didn't.
Required.*.JsonInput.StringFieldNotAString # Should have failed to parse, but didn't.
Required.*.ProtobufInput.UnknownOrdering.ProtobufOutput # Unknown field mismatch
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.
3 changes: 3 additions & 0 deletions conformance/failure_list_java_lite.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@

Required.*.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE # Should have failed to parse, but didn't.
Required.*.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE # Should have failed to parse, but didn't.
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.
3 changes: 3 additions & 0 deletions conformance/failure_list_jruby.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,6 @@ Required.Editions_Proto2.ProtobufInput.UnknownOrdering.ProtobufOutput
Required.Editions_Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput
Required.Proto2.ProtobufInput.UnknownOrdering.ProtobufOutput
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.
4 changes: 4 additions & 0 deletions conformance/failure_list_objc.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# 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.*.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.
4 changes: 4 additions & 0 deletions conformance/failure_list_php.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ Required.*.DurationProtoNanosWrongSignNegativeSecs.JsonOutput # Should have fail
Required.*.TimestampProtoNanoTooLarge.JsonOutput # Should have failed to serialize, but didn't.
Required.*.TimestampProtoNegativeNanos.JsonOutput # Should have failed to serialize, but didn't.
Required.*.JsonInput.SingleValueForRepeatedFieldInt32 # Should have failed to parse, but didn't.
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.*.ProtobufInput.BadTag_VarintMoreThanTenBytes # Should have failed to parse, but didn't.
3 changes: 3 additions & 0 deletions conformance/failure_list_python.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
Recommended.*.JsonInput.FieldNameDuplicateDifferentCasing1 # Should have failed to parse, but didn't.
Recommended.*.JsonInput.FieldNameDuplicateDifferentCasing2 # Should have failed to parse, but didn't.
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.
1 change: 1 addition & 0 deletions conformance/failure_list_python_cpp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

Recommended.*.JsonInput.FieldNameDuplicateDifferentCasing1 # Should have failed to parse, but didn't.
Recommended.*.JsonInput.FieldNameDuplicateDifferentCasing2 # Should have failed to parse, but didn't.
Required.*.ProtobufInput.BadTag_FieldNumberSlightlyTooHigh # Should have failed to parse, but didn't.
1 change: 1 addition & 0 deletions conformance/failure_list_rust_cc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Required.*.ProtobufInput.BadTag_FieldNumberSlightlyTooHigh # Should have failed to parse, but didn't.
Loading