From 394648c7948b231c304342e4ddada07e4a110a3d Mon Sep 17 00:00:00 2001 From: Jakub Witczak Date: Fri, 27 Jan 2023 17:13:31 +0100 Subject: ssh: reduce log length --- lib/ssh/src/ssh_connection_handler.erl | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl index b2545c4db4..9ab16c6ad7 100644 --- a/lib/ssh/src/ssh_connection_handler.erl +++ b/lib/ssh/src/ssh_connection_handler.erl @@ -1091,8 +1091,10 @@ handle_event(info, {Proto, Sock, Info}, {hello,_}, #data{socket = Sock, end; -handle_event(info, {Proto, Sock, NewData}, StateName, D0 = #data{socket = Sock, - transport_protocol = Proto}) -> +handle_event(info, {Proto, Sock, NewData}, StateName, + D0 = #data{socket = Sock, + transport_protocol = Proto, + ssh_params = SshParams}) -> try ssh_transport:handle_packet_part( D0#data.decrypted_data_buffer, <<(D0#data.encrypted_data_buffer)/binary, NewData/binary>>, @@ -1136,10 +1138,11 @@ handle_event(info, {Proto, Sock, NewData}, StateName, D0 = #data{socket = Sock, ]} catch C:E:ST -> - {Shutdown, D} = + MaxLogItemLen = ?GET_OPT(max_log_item_len,SshParams#ssh.opts), + {Shutdown, D} = ?send_disconnect(?SSH_DISCONNECT_PROTOCOL_ERROR, - io_lib:format("Bad packet: Decrypted, but can't decode~n~p:~p~n~p", - [C,E,ST]), + io_lib:format("Bad packet: Decrypted, but can't decode~n~p:~p~n~P", + [C,E,ST,MaxLogItemLen]), StateName, D1), {stop, Shutdown, D} end; @@ -1170,9 +1173,11 @@ handle_event(info, {Proto, Sock, NewData}, StateName, D0 = #data{socket = Sock, {stop, Shutdown, D} catch C:E:ST -> - {Shutdown, D} = + MaxLogItemLen = ?GET_OPT(max_log_item_len,SshParams#ssh.opts), + {Shutdown, D} = ?send_disconnect(?SSH_DISCONNECT_PROTOCOL_ERROR, - io_lib:format("Bad packet: Couldn't decrypt~n~p:~p~n~p",[C,E,ST]), + io_lib:format("Bad packet: Couldn't decrypt~n~p:~p~n~P", + [C,E,ST,MaxLogItemLen]), StateName, D0), {stop, Shutdown, D} end; -- cgit v1.2.1