aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2017-08-11 10:14:24 +0100
committerJon Skeet <skeet@pobox.com>2017-08-11 19:33:53 +0100
commite0d24cc84a81d236daf0bbf783037c8c8c24d814 (patch)
treeb188007bf2bbba2ccf372fc9d7bf9c3acc944ea1 /csharp/src/Google.Protobuf
parentccb6b622497c9627898dadcb3818014b3a245d4e (diff)
downloadprotobuf-e0d24cc84a81d236daf0bbf783037c8c8c24d814.tar.gz
protobuf-e0d24cc84a81d236daf0bbf783037c8c8c24d814.tar.bz2
protobuf-e0d24cc84a81d236daf0bbf783037c8c8c24d814.zip
Detect invalid tags with a field number of 0 in C#
Previously we only rejected the tag if the tag itself was 0, i.e. field=0, type=varint. The type doesn't matter: field 0 is always invalid. This removes the last of the C# conformance failures.
Diffstat (limited to 'csharp/src/Google.Protobuf')
-rw-r--r--csharp/src/Google.Protobuf/CodedInputStream.cs4
1 files changed, 2 insertions, 2 deletions
diff --git a/csharp/src/Google.Protobuf/CodedInputStream.cs b/csharp/src/Google.Protobuf/CodedInputStream.cs
index 84f90a25..abd352b9 100644
--- a/csharp/src/Google.Protobuf/CodedInputStream.cs
+++ b/csharp/src/Google.Protobuf/CodedInputStream.cs
@@ -373,9 +373,9 @@ namespace Google.Protobuf
lastTag = ReadRawVarint32();
}
- if (lastTag == 0)
+ if (WireFormat.GetTagFieldNumber(lastTag) == 0)
{
- // If we actually read zero, that's not a valid tag.
+ // If we actually read a tag with a field of 0, that's not a valid tag.
throw InvalidProtocolBufferException.InvalidTag();
}
return lastTag;