From f29538e8002cf0e37fa4f988fbf5484c46513bf4 Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Wed, 17 Feb 2010 15:49:22 +0000 Subject: OTP-8459 Do a controlled shutdown if a non ssl packet arrives as the first packet. --- lib/ssl/src/ssl_connection.erl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib/ssl/src/ssl_connection.erl') diff --git a/lib/ssl/src/ssl_connection.erl b/lib/ssl/src/ssl_connection.erl index bbffa1e564..eaa022ed29 100644 --- a/lib/ssl/src/ssl_connection.erl +++ b/lib/ssl/src/ssl_connection.erl @@ -1429,12 +1429,10 @@ encode_handshake(HandshakeRec, SigAlg, Version, ConnectionStates0, Hashes0) -> encode_packet(Data, #socket_options{packet=Packet}) -> case Packet of - 0 -> Data; 1 -> encode_size_packet(Data, 8, (1 bsl 8) - 1); 2 -> encode_size_packet(Data, 16, (1 bsl 16) - 1); 4 -> encode_size_packet(Data, 32, (1 bsl 32) - 1); - _ -> - throw({error, {badarg, {eoptions, {packet, Packet}}}}) + _ -> Data end. encode_size_packet(Bin, Size, Max) -> @@ -1732,9 +1730,13 @@ handle_own_alert(Alert, Version, StateName, role = Role, connection_states = ConnectionStates, log_alert = Log}) -> - {BinMsg, _} = - encode_alert(Alert, Version, ConnectionStates), - Transport:send(Socket, BinMsg), + try + {BinMsg, _} = + encode_alert(Alert, Version, ConnectionStates), + Transport:send(Socket, BinMsg) + catch _:_ -> %% Can crash if we are in a uninitialized state + ignore + end, log_alert(Log, StateName, Alert), alert_user(User, Alert, Role). -- cgit v1.2.3