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

make System.Security.Cryptography.X509Certificates compliant with interop guidelines - part 4 #61986

Merged
merged 3 commits into from
Dec 2, 2021

Conversation

pedrobsaila
Copy link
Contributor

Fixes partially #51564

The is the final PR! it makes the following calls compliant with Interop guidelines :

  • System.Security.Cryptography.Native.CryptoNative_CheckX509Hostname
  • Crypt32.CryptQueryObject
  • libc.chmod
  • libc.geteuid

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Nov 23, 2021
@ghost
Copy link

ghost commented Nov 23, 2021

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

Issue Details

Fixes partially #51564

The is the final PR! it makes the following calls compliant with Interop guidelines :

  • System.Security.Cryptography.Native.CryptoNative_CheckX509Hostname
  • Crypt32.CryptQueryObject
  • libc.chmod
  • libc.geteuid
Author: pedrobsaila
Assignees: -
Labels:

area-System.Security, community-contribution

Milestone: -

@AaronRobinsonMSFT
Copy link
Member

/cc @jkoritzinsky @elinor-fung

@@ -51,7 +36,7 @@ IntPtr ppvContext
IntPtr pdwFormatType,
out SafeCertStoreHandle phCertStore,
IntPtr phMsg,
IntPtr ppvContext
out IntPtr ppvContext
);
Copy link
Member

Choose a reason for hiding this comment

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

This change causes us to pass a pointer in (to receive the value) when we used to pass NULL. That potentially changes the allocation behavior of the called function and may make us need to call a free on the emitted value.. which we're not doing.

This change needs to be undone.

Copy link
Contributor Author

@pedrobsaila pedrobsaila Nov 29, 2021

Choose a reason for hiding this comment

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

Should I rollback also the added parameter modifier 'out' inside this overload src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptQueryObject_IntPtr.cs ? The test System.Security.Cryptography.X509Certificates.Tests.TestHandle.TestHandleCtor use this overload and needs the pointer to pass ?

Copy link
Member

@bartonjs bartonjs Nov 29, 2021

Choose a reason for hiding this comment

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

If the tests are the only thing using the IntPtr variant, and they're using the last parameter differently, then the _IntPtr variant can keep the out; but the existing variant needs to go back to non-out.

If there is overlap, then I think we can change it to ref IntPtr and the existing calls can pass ref Unsafe.NullRef<IntPtr>() but we shouldn't do that unless there's a demonstrated need.

Copy link
Member

Choose a reason for hiding this comment

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

Since overloading is allowed across by-value and out, I wouldn't combine them, just leave them as overloads. We might squish them down into one later, but overloading for now seems the easiest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created an overload src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptQueryObject_IntPtr_out.cs for test project that have the out modifier on ppvContext parameter, and rollbacked the modifier on pre-existing overloads

@bartonjs bartonjs merged commit 841b323 into dotnet:main Dec 2, 2021
@bartonjs
Copy link
Member

bartonjs commented Dec 2, 2021

Thanks for taking care of this, @pedrobsaila.

@pedrobsaila
Copy link
Contributor Author

You're welcome @bartonjs 😄 , thanks to you too. I wouldn't have done it without your guidance

@pedrobsaila pedrobsaila deleted the 51564/part5 branch December 3, 2021 10:32
@ghost ghost locked as resolved and limited conversation to collaborators Jan 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Security community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants