[C#] fix parse failure for extensions with large field numbers (#9591)

pull/9594/head
Junrou Nishida 3 years ago committed by GitHub
parent 349d74d92e
commit 92cdf87f1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs
  2. 2
      csharp/src/Google.Protobuf/WireFormat.cs

@ -716,6 +716,25 @@ namespace Google.Protobuf
}
}
[Test]
public void MaximumFieldNumber()
{
MemoryStream ms = new MemoryStream();
CodedOutputStream output = new CodedOutputStream(ms);
int fieldNumber = 0x1FFFFFFF;
uint tag = WireFormat.MakeTag(fieldNumber, WireFormat.WireType.LengthDelimited);
output.WriteRawVarint32(tag);
output.WriteString("field 1");
output.Flush();
ms.Position = 0;
CodedInputStream input = new CodedInputStream(ms);
Assert.AreEqual(tag, input.ReadTag());
Assert.AreEqual(fieldNumber, WireFormat.GetTagFieldNumber(tag));
}
[Test]
public void Tag0Throws()
{

@ -90,7 +90,7 @@ namespace Google.Protobuf
/// </summary>
public static int GetTagFieldNumber(uint tag)
{
return (int) tag >> TagTypeBits;
return (int) (tag >> TagTypeBits);
}
/// <summary>

Loading…
Cancel
Save