You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
MessageParser.ParseFrom should throw InvalidProtocolBufferException when parsing invalid message, but it can also throw several other unexpected exceptions:
ArgumentException
ArgumentOutOfRangeException
InvalidOperationException
The following C# program demonstrates this:
using System;using Sample;namespace Google.Protobuf.Run
{publicclassProgram{publicstaticvoidMain(string[]args){try{varbytes=newbyte[]{34,255,255,255,255,7,34,255,255,101};
Person.Parser.ParseFrom(bytes);}catch(ArgumentException){}try{varbytes=newbyte[]{10,247,181,144,151,110,32,68,111,101,16,210,9,26,16,106,100,111,101,64,101,120,97,109,112,108,101,46,99,111,109,34,12,10,8,53,53,53,45,52,51,50,49,16,1};
Person.Parser.ParseFrom(bytes);}catch(ArgumentOutOfRangeException){}try{varbytes=newbyte[]{14,8,74,111,104,110,32,68,111,101,16,210,9,26,16,106,100,111,101,64,101,120,97,109,112,108,101,46,99,111,109,34,12,10,8,53,53,53,45,52,51,50,59,16,1};
Person.Parser.ParseFrom(bytes);}catch(InvalidOperationException){}}}}
Generated C# code for the Person class is in the attached archive.
I'm using .NET Core 2.1 and the latest NuGet version of the Google.Protobuf package (version 3.6.1).
* Fix#5513
* Added tests for invalid lengths when reading strings and bytes.
Added test for reading tags with invalid wire types in unknown field set.
Changed invalid length check in ReadString to match the one in ReadBytes
MessageParser.ParseFrom should throw InvalidProtocolBufferException when parsing invalid message, but it can also throw several other unexpected exceptions:
The following C# program demonstrates this:
Proto definition of the Person class:
Generated C# code for the Person class is in the attached archive.
I'm using .NET Core 2.1 and the latest NuGet version of the Google.Protobuf package (version 3.6.1).
Found via SharpFuzz.
The text was updated successfully, but these errors were encountered: