New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializer.Deserialize can throw many unexpected exceptions #481

Open
Metalnem opened this Issue Dec 25, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@Metalnem
Copy link

Metalnem commented Dec 25, 2018

Serializer.Deserialize can throw many unexpected exceptions (IOException and ProtoException are expected in my opinion) when deserializing files from the attached archive. These are:

  • ArgumentException
  • IndexOutOfRangeException
  • InvalidOperationException
  • OverflowException

Here's the full program to reproduce this (args[0] should contain the path to one of the extracted files):

using System.IO;
using ProtoBuf;

namespace protobuf_net.Run
{
[ProtoContract]
  public class Person
  {
    [ProtoMember(1)] public int Id { get; set; }
    [ProtoMember(2)] public string Name { get; set; }
    [ProtoMember(3)] public Address Address { get; set; }
  }

  [ProtoContract]
  public class Address
  {
    [ProtoMember(1)] public string Line1 { get; set; }
    [ProtoMember(2)] public string Line2 { get; set; }
  }

  public class Program
  {
    public static void Main(string[] args)
    {
      using (var file = File.OpenRead(args[0]))
      {
        Serializer.Deserialize<Person>(file);
      }
    }
  }
}

Found via SharpFuzz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment