File 0934-ssl-Avoid-possible-sending-an-active-message-to-a-pa.patch of Package erlang
From 5a9a2fe727ba43bd6352552d42db85255b4fd4ff Mon Sep 17 00:00:00 2001
From: Ingela Anderton Andin <ingela@erlang.org>
Date: Thu, 28 May 2020 11:01:00 +0200
Subject: [PATCH 1/3] ssl: Avoid possible sending an active message to a
passive socket
In the corner case that a passive socket is started and ssl:recv never is called
and the other side closes the socket, an active close message could incorrectly
be sent to a passive socket.
---
lib/ssl/src/ssl_connection.erl | 8 ++++----
lib/ssl/test/ssl_api_SUITE.erl | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/lib/ssl/src/ssl_connection.erl b/lib/ssl/src/ssl_connection.erl
index 8e2e794280..e1a0ce9079 100644
--- a/lib/ssl/src/ssl_connection.erl
+++ b/lib/ssl/src/ssl_connection.erl
@@ -2981,11 +2981,11 @@ header(N, Binary) ->
send_or_reply(false, _Pid, From, Data) when From =/= undefined ->
gen_statem:reply(From, Data);
-%% Can happen when handling own alert or tcp error/close and there is
-%% no outstanding gen_fsm sync events
-send_or_reply(false, no_pid, _, _) ->
+send_or_reply(false, Pid, undefined, _) when is_pid(Pid) ->
ok;
-send_or_reply(_, Pid, _From, Data) ->
+send_or_reply(_, no_pid, _, _) ->
+ ok;
+send_or_reply(_, Pid, _, Data) ->
send_user(Pid, Data).
send_user(Pid, Msg) ->
--
2.26.2