Skip to content

Reduce the nullability bypasses in CryptoPool.Return - #55782

Merged
stephentoub merged 2 commits into
dotnet:mainfrom
bartonjs:cryptopool_return_nullability
Jul 18, 2021
Merged

Reduce the nullability bypasses in CryptoPool.Return#55782
stephentoub merged 2 commits into
dotnet:mainfrom
bartonjs:cryptopool_return_nullability

Conversation

@bartonjs

Copy link
Copy Markdown
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.
@bartonjsbartonjs added this to the 6.0.0 milestone Jul 15, 2021
@bartonjsbartonjs self-assigned this Jul 15, 2021
@ghost

Copy link
Copy Markdown

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
Copy Markdown
MemberAuthor

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

Comment threadsrc/libraries/Common/src/System/Security/Cryptography/RSAAndroid.cs Outdated
Comment threadsrc/libraries/Common/src/System/Security/Cryptography/RSAOpenSsl.cs Outdated
Co-authored-by: Stephen Toub <stoub@microsoft.com>
@stephentoub
stephentoub merged commit 6b6310b into dotnet:mainJul 18, 2021
@bartonjs
bartonjs deleted the cryptopool_return_nullability branch July 18, 2021 19:43
@bartonjsbartonjs removed their assignment Jul 26, 2021
@ghostghost locked as resolved and limited conversation to collaborators Aug 25, 2021
Sign up for freeto 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

@bartonjs@vcsjones@stephentoub