From: Tomas Weinfurt Date: Mon, 6 Feb 2023 19:32:59 +0000 (-0800) Subject: prevent use of null when processing alpn list (#81629) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~4208 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fb25b76d3b4873153964558aec267a8b0c0ae31c;p=platform%2Fupstream%2Fdotnet%2Fruntime.git prevent use of null when processing alpn list (#81629) --- diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs index 1bfaff2..e485326 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs @@ -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); diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs index 986754d..d5788bb 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Ssl.cs @@ -421,6 +421,7 @@ namespace Microsoft.Win32.SafeHandles if (AlpnHandle.IsAllocated) { + Interop.Ssl.SslSetData(handle, IntPtr.Zero); AlpnHandle.Free(); }