aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssl/src
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2011-06-09 12:18:34 +0200
committerIngela Anderton Andin <[email protected]>2011-06-09 12:18:34 +0200
commit751ec4f918bed2f5455538e6296c6b925bcca002 (patch)
treed983ce771c1a96a89a96abbf7fca46fb00fc5708 /lib/ssl/src
parent3b818d5ec09cd2bb4c650776b898af9206f13c68 (diff)
parent8f74c4a943269ab5eb1e6177282e5fb8c765d3b7 (diff)
downloadotp-751ec4f918bed2f5455538e6296c6b925bcca002.tar.gz
otp-751ec4f918bed2f5455538e6296c6b925bcca002.tar.bz2
otp-751ec4f918bed2f5455538e6296c6b925bcca002.zip
Merge branch 'ia/ssl/denial-of-service/OTP-9364' into dev
* ia/ssl/denial-of-service/OTP-9364: Prevention of denial of service attack
Diffstat (limited to 'lib/ssl/src')
-rw-r--r--lib/ssl/src/ssl_record.erl16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/ssl/src/ssl_record.erl b/lib/ssl/src/ssl_record.erl
index f1c0073965..4c3c0b9c58 100644
--- a/lib/ssl/src/ssl_record.erl
+++ b/lib/ssl/src/ssl_record.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2007-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2007-2011. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -62,6 +62,8 @@
-compile(inline).
+-define(INITIAL_BYTES, 5).
+
%%====================================================================
%% Internal application API
%%====================================================================
@@ -360,16 +362,20 @@ get_tls_records_aux(<<1:1, Length0:15, Data0:Length0/binary, Rest/binary>>,
get_tls_records_aux(<<0:1, _CT:7, ?BYTE(_MajVer), ?BYTE(_MinVer),
?UINT16(Length), _/binary>>,
- _Acc) when Length > ?MAX_CIPHER_TEXT_LENGTH->
+ _Acc) when Length > ?MAX_CIPHER_TEXT_LENGTH ->
?ALERT_REC(?FATAL, ?RECORD_OVERFLOW);
get_tls_records_aux(<<1:1, Length0:15, _/binary>>,_Acc)
- when Length0 > ?MAX_CIPHER_TEXT_LENGTH->
+ when Length0 > ?MAX_CIPHER_TEXT_LENGTH ->
?ALERT_REC(?FATAL, ?RECORD_OVERFLOW);
get_tls_records_aux(Data, Acc) ->
- {lists:reverse(Acc), Data}.
-
+ case size(Data) =< ?MAX_CIPHER_TEXT_LENGTH + ?INITIAL_BYTES of
+ true ->
+ {lists:reverse(Acc), Data};
+ false ->
+ ?ALERT_REC(?FATAL, ?UNEXPECTED_MESSAGE)
+ end.
%%--------------------------------------------------------------------
-spec protocol_version(tls_atom_version() | tls_version()) ->
tls_version() | tls_atom_version().