diff options
author | Ingela Anderton Andin <[email protected]> | 2012-02-20 14:00:01 +0100 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2012-02-20 14:00:01 +0100 |
commit | 7e44054e5292f6b010bb4a9c13fe01843e15d802 (patch) | |
tree | 49b6360960a0593eae0809dd7b52e159612f896d /lib | |
parent | 0e4ae2a2b5d291b5e918f3ab9e675c4137d1888b (diff) | |
download | otp-7e44054e5292f6b010bb4a9c13fe01843e15d802.tar.gz otp-7e44054e5292f6b010bb4a9c13fe01843e15d802.tar.bz2 otp-7e44054e5292f6b010bb4a9c13fe01843e15d802.zip |
Improve check so that we will not try to read ssh packet length indicator if not sure we have enough data.
OTP-8380
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ssh/src/ssh_connection_handler.erl | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl index 670250730d..b3319fc809 100644 --- a/lib/ssh/src/ssh_connection_handler.erl +++ b/lib/ssh/src/ssh_connection_handler.erl @@ -837,13 +837,18 @@ generate_event_new_state(#state{ssh_params = next_packet(#state{decoded_data_buffer = <<>>, encoded_data_buffer = Buff, + ssh_params = #ssh{decrypt_block_size = BlockSize}, socket = Socket, - transport_protocol = Protocol} = - State) when Buff =/= <<>> andalso size(Buff) >= 8 -> - %% More data from the next packet has been received - %% Fake a socket-recive message so that the data will be processed - inet:setopts(Socket, [{active, once}]), - self() ! {Protocol, Socket, <<>>}, + transport_protocol = Protocol} = State) when Buff =/= <<>> -> + case size(Buff) >= erlang:max(8, BlockSize) of + true -> + %% Enough data from the next packet has been received to + %% decode the length indicator, fake a socket-recive + %% message so that the data will be processed + self() ! {Protocol, Socket, <<>>}; + false -> + inet:setopts(Socket, [{active, once}]) + end, State; next_packet(#state{socket = Socket} = State) -> |