aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssl/src
diff options
context:
space:
mode:
authorDanil Zagoskin <[email protected]>2014-04-20 02:25:42 +0400
committerIngela Anderton Andin <[email protected]>2014-04-23 15:59:10 +0200
commitabb5c21e25343139e47559dbf9a22d099f97154f (patch)
treeae2ee950ef7b627f09ce3e28f37f7b54dc3f4819 /lib/ssl/src
parent081ee510f1fb1d821a524bd6b8efd20e520add3c (diff)
downloadotp-abb5c21e25343139e47559dbf9a22d099f97154f.tar.gz
otp-abb5c21e25343139e47559dbf9a22d099f97154f.tar.bz2
otp-abb5c21e25343139e47559dbf9a22d099f97154f.zip
ssl: Fix crash on garbage during handshake
If a client sends some garbage in ssl record instead of valid fragment, server crashes with function_clause while receiving next record from client. This patch makes server raise handshake failure instead of crashing and exposing internal state to user code.
Diffstat (limited to 'lib/ssl/src')
-rw-r--r--lib/ssl/src/tls_connection.erl6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/ssl/src/tls_connection.erl b/lib/ssl/src/tls_connection.erl
index 8142a18c37..930706cde6 100644
--- a/lib/ssl/src/tls_connection.erl
+++ b/lib/ssl/src/tls_connection.erl
@@ -751,7 +751,11 @@ handle_tls_handshake(Handle, StateName,
handle_tls_handshake(Handle, NextStateName, State);
{stop, _,_} = Stop ->
Stop
- end.
+ end;
+
+handle_tls_handshake(_Handle, _StateName, #state{}) ->
+ throw(?ALERT_REC(?FATAL, ?HANDSHAKE_FAILURE)).
+
write_application_data(Data0, From,
#state{socket = Socket,
negotiated_version = Version,