diff options
author | Alexander Köplinger <alex.koeplinger@outlook.com> | 2019-12-19 04:25:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-19 04:25:06 +0300 |
commit | c8e19bec68962679553ad164145e9952180e3bf2 (patch) | |
tree | 389f3d65811b8c5752d65a68d7d5c6bbfbb80981 /mcs/class | |
parent | e7b98d3587fddd51db69baddb370321cca521d60 (diff) |
[System] Add additional hardening against race in MonoTlsStream (#18250)
See https://github.com/mono/mono/issues/15805#issuecomment-567131297
Diffstat (limited to 'mcs/class')
-rw-r--r-- | mcs/class/System/Mono.Net.Security/MonoTlsStream.cs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/mcs/class/System/Mono.Net.Security/MonoTlsStream.cs b/mcs/class/System/Mono.Net.Security/MonoTlsStream.cs index 935df6acaf0..71217446e1b 100644 --- a/mcs/class/System/Mono.Net.Security/MonoTlsStream.cs +++ b/mcs/class/System/Mono.Net.Security/MonoTlsStream.cs @@ -64,6 +64,7 @@ namespace Mono.Net.Security } SslStream sslStream; + readonly object sslStreamLock = new object (); internal SslStream SslStream { get { return sslStream; } @@ -157,9 +158,11 @@ namespace Mono.Net.Security } void CloseSslStream () { - if (sslStream != null) { - sslStream.Dispose (); - sslStream = null; + lock (sslStreamLock) { + if (sslStream != null) { + sslStream.Dispose (); + sslStream = null; + } } } } |