Skip to content

BinaryFormatter.Deserialize throws many unexpected exceptions #28750

@Metalnem

Description

@Metalnem

The documentation says that the BinaryFormatter.Deserialize method may throw SerializationException or SecurityException, but it can actually throw many more. Here are some of them:

  • ArgumentException
  • ArgumentOutOfRangeException
  • DecoderFallbackException
  • FileLoadException
  • FormatException
  • IndexOutOfRangeException
  • IOException
  • MemberAccessException
  • NullReferenceException
  • OverflowException

To reproduce all of these, just run the project from the attached archive.

My environment:

.NET Core SDK (reflecting any global.json):
 Version:   2.2.104
 Commit:    73f036d4ac

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.2.104/

Found via SharpFuzz.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Runtimegood first issueIssue should be easy to implement, good for first-time contributorshelp wanted[up-for-grabs] Good issue for external contributors

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions