aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssl/src/ssl_connection.erl
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2010-02-17 15:49:22 +0000
committerErlang/OTP <[email protected]>2010-02-17 16:55:20 +0100
commitf29538e8002cf0e37fa4f988fbf5484c46513bf4 (patch)
tree494a29d8a00cd872194ea3f2128a3364aa732866 /lib/ssl/src/ssl_connection.erl
parent8b39d0582bee5d4071b7ae4c7407d6662c0414a9 (diff)
downloadotp-f29538e8002cf0e37fa4f988fbf5484c46513bf4.tar.gz
otp-f29538e8002cf0e37fa4f988fbf5484c46513bf4.tar.bz2
otp-f29538e8002cf0e37fa4f988fbf5484c46513bf4.zip
OTP-8459 Do a controlled shutdown if a non ssl packet arrives as the first
packet.
Diffstat (limited to 'lib/ssl/src/ssl_connection.erl')
-rw-r--r--lib/ssl/src/ssl_connection.erl14
1 files changed, 8 insertions, 6 deletions
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).