prevent use of null when processing alpn list (#81629)
authorTomas Weinfurt <tweinfurt@yahoo.com>
Mon, 6 Feb 2023 19:32:59 +0000 (11:32 -0800)
committerGitHub <noreply@github.com>
Mon, 6 Feb 2023 19:32:59 +0000 (11:32 -0800)
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs

index 1bfaff2..e485326 100644 (file)
@@ -683,6 +683,11 @@ internal static partial class Interop
             *outlen = 0;
             IntPtr sslData = Ssl.SslGetData(ssl);
 
+            if (sslData == IntPtr.Zero)
+            {
+                return Ssl.SSL_TLSEXT_ERR_ALERT_FATAL;
+            }
+
             // reset application data to avoid dangling pointer.
             Ssl.SslSetData(ssl, IntPtr.Zero);
 
index 986754d..d5788bb 100644 (file)
@@ -421,6 +421,7 @@ namespace Microsoft.Win32.SafeHandles
 
             if (AlpnHandle.IsAllocated)
             {
+                Interop.Ssl.SslSetData(handle, IntPtr.Zero);
                 AlpnHandle.Free();
             }