File 0694-ssl-Handle-internal-socket-activation-in-state-downg.patch of Package erlang
From cae7e609af8952912c1171f023cb0e7635ba5081 Mon Sep 17 00:00:00 2001
From: Ingela Anderton Andin <ingela@erlang.org>
Date: Wed, 22 Jan 2020 16:22:48 +0100
Subject: [PATCH] ssl: Handle internal socket activation in state downgrade
We must only use active once instead of N to make sure we only receive
the close alert and not any later TCP data.
---
lib/ssl/src/tls_connection.erl | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/lib/ssl/src/tls_connection.erl b/lib/ssl/src/tls_connection.erl
index babcf9f6c5..c5264e986d 100644
--- a/lib/ssl/src/tls_connection.erl
+++ b/lib/ssl/src/tls_connection.erl
@@ -751,15 +751,19 @@ connection({call, From}, {user_renegotiate, WriteState},
[{next_event,{call, From}, renegotiate}]};
connection({call, From},
{close, {Pid, _Timeout}},
- #state{connection_env = #connection_env{terminated = closed} =CEnv} = State) ->
+ #state{connection_env = #connection_env{terminated = closed} = CEnv,
+ protocol_specific = PS} = State) ->
{next_state, downgrade, State#state{connection_env =
- CEnv#connection_env{terminated = true,
- downgrade = {Pid, From}}},
+ CEnv#connection_env{terminated = true,
+ downgrade = {Pid, From}},
+ protocol_specific = PS#{active_n_toggle => true,
+ active_n => 1}
+ },
[{next_event, internal, ?ALERT_REC(?WARNING, ?CLOSE_NOTIFY)}]};
connection({call, From},
{close,{Pid, Timeout}},
#state{connection_states = ConnectionStates,
- protocol_specific = #{sender := Sender},
+ protocol_specific = #{sender := Sender} = PS,
connection_env = CEnv
} = State0) ->
case tls_sender:downgrade(Sender, Timeout) of
@@ -773,7 +777,10 @@ connection({call, From},
ConnectionStates#{current_write => Write}}),
{next_state, downgrade, State#state{connection_env =
CEnv#connection_env{downgrade = {Pid, From},
- terminated = true}},
+ terminated = true},
+ protocol_specific = PS#{active_n_toggle => true,
+ active_n => 1}
+ },
[{timeout, Timeout, downgrade}]};
{error, timeout} ->
{stop_and_reply, {shutdown, downgrade_fail}, [{reply, From, {error, timeout}}]}
--
2.16.4