Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Avoid non documented exceptions in BinaryFormatter.Deserialize #40215

Merged
merged 3 commits into from
Oct 8, 2019

Conversation

birkmose
Copy link
Contributor

Fixes #35491. BinaryFormatter.Deserialize can throw other exceptions than those specified in the documentation (SerializationException, SecurityException & ArgumentNullException) in cases of corrupt input. This update changes the BinaryFormatter.Deserialize method to wrap those "internal" exception inside an SerializationException.

…ceptions than those specified in the documentation (only supposed to throw SerializationException or SecurityException).
@dnfclas
Copy link

dnfclas commented Aug 10, 2019

CLA assistant check
All CLA requirements met.

…f BinaryFormatter.Deserialize. Fix naming error in SerializationGuardTests.
@birkmose
Copy link
Contributor Author

Any feedback on this? This is my first pull request - so not sure if I did everything right? :)

@stephentoub
Copy link
Member

cc: @ViktorHofer

@stephentoub stephentoub added this to the 5.0 milestone Aug 15, 2019
Copy link
Member

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. My only concern here is that this could break customers who rely on raw exceptions being thrown.

@birkmose
Copy link
Contributor Author

@ViktorHofer I think thats a valid concern, but I guess that would also be relying on undocumented/undefined behaviour? If nothing else with the change the consumer of the API still has access to the internal exception via innerException.

@ViktorHofer
Copy link
Member

that would also be relying on undocumented/undefined behaviour

Right, but we should still make sure that we know the impact of a breaking change. I don't know how many customers currently rely on this undocumented behavior. We might want to gather some data before merging.

cc @leecow

@leecow
Copy link
Member

leecow commented Aug 22, 2019

I think this warrants a breaking change announcement on https://github.com/dotnet/announcements/issues.

@birkmose
Copy link
Contributor Author

Hi @leecow,
Anything further I should do? I take it announcements is something MS does if/when this is merged?

@leecow
Copy link
Member

leecow commented Aug 22, 2019

Yes. @ViktorHofer, can you help with that when the time comes?

@danmoseley
Copy link
Member

@ViktorHofer what's next steps here? One option is: take the change, since we have some time until we ship, and we will have many preview releases on the way.

@ViktorHofer
Copy link
Member

Yes, taking the change now in an early stage sounds reasonable. And yes, I can help with the announcement.

@ViktorHofer
Copy link
Member

/azp run corefx-ci

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@birkmose
Copy link
Contributor Author

birkmose commented Oct 8, 2019

/azp run corefx-ci

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 40215 in repo dotnet/corefx

@ViktorHofer
Copy link
Member

The failing test is https://github.com/dotnet/corefx/issues/29742#issuecomment-539585555. I'm fine with merging this.

@ViktorHofer
Copy link
Member

Thanks a lot @birkmose!

@ViktorHofer ViktorHofer merged commit 1736bfa into dotnet:master Oct 8, 2019
@birkmose
Copy link
Contributor Author

birkmose commented Oct 8, 2019

@ViktorHofer I was actually trying to reproduce right now in my personal tree, but didn't seem to be related to this PR - not BinarySerializer references here :)

RussKie pushed a commit to dotnet/winforms that referenced this pull request Oct 24, 2019
…0191022.10

- Microsoft.NETCore.App - 5.0.0-alpha1.19522.10

Dependency coherency updates

- Microsoft.NETCore.Platforms - 5.0.0-alpha1.19521.4 (parent: Microsoft.NETCore.App)
- Microsoft.Win32.Registry - 5.0.0-alpha1.19521.4 (parent: Microsoft.NETCore.App)
- Microsoft.Win32.SystemEvents - 5.0.0-alpha1.19521.4 (parent: Microsoft.NETCore.App)
- System.CodeDom - 5.0.0-alpha1.19521.4 (parent: Microsoft.NETCore.App)
- System.Configuration.ConfigurationManager - 5.0.0-alpha1.19521.4 (parent: Microsoft.NETCore.App)
- System.Drawing.Common - 5.0.0-alpha1.19521.4 (parent: Microsoft.NETCore.App)
- System.Resources.Extensions - 5.0.0-alpha1.19521.4 (parent: Microsoft.NETCore.App)
- System.Security.Cryptography.Cng - 5.0.0-alpha1.19521.4 (parent: Microsoft.NETCore.App)
- System.Security.Permissions - 5.0.0-alpha1.19521.4 (parent: Microsoft.NETCore.App)
- System.Windows.Extensions - 5.0.0-alpha1.19521.4 (parent: Microsoft.NETCore.App)
- Microsoft.NET.Sdk.IL - 5.0.0-alpha1.19522.3 (parent: Microsoft.NETCore.App)
- Microsoft.NETCore.ILAsm - 5.0.0-alpha1.19522.3 (parent: Microsoft.NETCore.App)

Fix tests to account for dotnet/corefx#40215
@DmitryGaravsky
Copy link

Hi all.
Please, take a look at the https://github.com/dotnet/corefx/issues/42817 related to this PR.

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…t/corefx#40215)

* dotnet/corefx#35491 Fixes issue with BinaryFormatter.Deserialize throwing other exceptions than those specified in the documentation (only supposed to throw SerializationException or SecurityException).

* Update UnitySerializationHolderTests to test the expected behaviour of BinaryFormatter.Deserialize. Fix naming error in SerializationGuardTests.


Commit migrated from dotnet/corefx@1736bfa
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants