Skip to content

Commit 899ffec

Browse files
committed
dtls: Avoid continuing event handling when reciving duplicte chang_ciphr_spec messages
Found when looking into issue 11075
1 parent 7e03f3c commit 899ffec

1 file changed

Lines changed: 6 additions & 20 deletions

File tree

lib/ssl/src/dtls_server_connection.erl

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -296,17 +296,10 @@ hello(internal, {handshake, {#client_hello{cookie = <<>>} = Handshake, _}}, Stat
296296
{next_state, ?STATE(hello), State, [{next_event, internal, Handshake}]};
297297
hello(internal, #change_cipher_spec{type = <<1>>}, State0) ->
298298
Epoch = dtls_gen_connection:retransmit_epoch(?STATE(hello), State0),
299-
{State1, Actions0} =
299+
{State, _} =
300300
dtls_gen_connection:send_handshake_flight(State0, Epoch),
301-
%% This will reset the retransmission timer by repeating the enter state event
302-
case dtls_gen_connection:next_event(?STATE(hello), no_record, State1, Actions0) of
303-
{next_state, ?FUNCTION_NAME, State, Actions} ->
304-
{repeat_state, State, Actions};
305-
{next_state, ?FUNCTION_NAME, State} ->
306-
{repeat_state, State};
307-
{stop, _, _} = Stop ->
308-
Stop
309-
end;
301+
%% Just retransmit and reset timer, don't process buffered records
302+
{repeat_state, State};
310303
hello(internal, {protocol_record, #ssl_tls{type = ?APPLICATION_DATA}},
311304
#state{handshake_env = #handshake_env{renegotiation = {false, first}}} = State) ->
312305
Alert = ?ALERT_REC(?FATAL, ?UNEXPECTED_MESSAGE, application_data_before_initial_handshake),
@@ -362,16 +355,9 @@ certify(enter, _, State0) ->
362355
{keep_state, State, Actions};
363356
certify(internal, #change_cipher_spec{type = <<1>>}, State0) ->
364357
Epoch = dtls_gen_connection:retransmit_epoch(?STATE(certify), State0),
365-
{State1, Actions0} = dtls_gen_connection:send_handshake_flight(State0, Epoch),
366-
%% This will reset the retransmission timer by repeating the enter state event
367-
case dtls_gen_connection:next_event(?STATE(certify), no_record, State1, Actions0) of
368-
{next_state, ?FUNCTION_NAME, State, Actions} ->
369-
{repeat_state, State, Actions};
370-
{next_state, ?FUNCTION_NAME, State} ->
371-
{repeat_state, State, Actions0};
372-
{stop, _, _} = Stop ->
373-
Stop
374-
end;
358+
{State, _} = dtls_gen_connection:send_handshake_flight(State0, Epoch),
359+
%% Just retransmit and reset timer, don't process buffered records
360+
{repeat_state, State};
375361
certify(state_timeout, Event, State) ->
376362
dtls_gen_connection:handle_state_timeout(Event, ?STATE(certify), State);
377363
certify(internal, {protocol_record, #ssl_tls{type = ?APPLICATION_DATA}},

0 commit comments

Comments
 (0)