Skip to content
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

Reduce the nullability bypasses in CryptoPool.Return #55782

Merged
merged 2 commits into from
Jul 18, 2021

Conversation

bartonjs
Copy link
Member

This is a walk over src/libraries/.../*.cs to find any calls to
CryptoPool.Return which needed a "!" because of nullability
flow.

A couple of the bypasses were identifying legitimate issues,
and were resolved by moving the Rent to the last thing before
the try.

A couple were because of the use of ArraySegment which
can't structurally promise the array is non-null. But those
were usually preceded by a call to ZeroMemory, and there
is a CryptoPool.Return(ArraySegment) which does that
already, so those "!"s were removed by changing to that
overload.

This is a walk over src/libraries/.../*.cs to find any calls to
CryptoPool.Return which needed a "!" because of nullability
flow.

A couple of the bypasses were identifying legitimate issues,
and were resolved by moving the Rent to the last thing before
the try.

A couple were because of the use of ArraySegment which
can't structurally promise the array is non-null. But those
were usually preceded by a call to ZeroMemory, and there
is a CryptoPool.Return(ArraySegment) which does that
already, so those "!"s were removed by changing to that
overload.
@bartonjs bartonjs added this to the 6.0.0 milestone Jul 15, 2021
@bartonjs bartonjs self-assigned this Jul 15, 2021
@ghost
Copy link

ghost commented Jul 15, 2021

Tagging subscribers to this area: @bartonjs, @vcsjones, @krwq, @GrabYourPitchforks
See info in area-owners.md if you want to be subscribed.

Issue Details

This is a walk over src/libraries/.../*.cs to find any calls to
CryptoPool.Return which needed a "!" because of nullability
flow.

A couple of the bypasses were identifying legitimate issues,
and were resolved by moving the Rent to the last thing before
the try.

A couple were because of the use of ArraySegment which
can't structurally promise the array is non-null. But those
were usually preceded by a call to ZeroMemory, and there
is a CryptoPool.Return(ArraySegment) which does that
already, so those "!"s were removed by changing to that
overload.

Author: bartonjs
Assignees: bartonjs
Labels:

area-System.Security

Milestone: 6.0.0

@bartonjs
Copy link
Member Author

This was the followup promised from #54282 (comment).

Co-authored-by: Stephen Toub <stoub@microsoft.com>
@stephentoub stephentoub merged commit 6b6310b into dotnet:main Jul 18, 2021
@bartonjs bartonjs deleted the cryptopool_return_nullability branch July 18, 2021 19:43
@bartonjs bartonjs removed their assignment Jul 26, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 25, 2021
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.

3 participants