From: Jakub Witczak <kuba@erlang.org>
Date: Fri, 21 Mar 2025 17:50:21 +0100
Subject: [PATCH] ssh: use chars_limit for bad packets error messages

origin: backport, https://github.com/erlang/otp/commit/d64d9fb0688092356a336e38a8717499113312a0
bug: https://github.com/erlang/otp/security/advisories/GHSA-vvr3-fjhh-cfwc
bug-debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1101713
---
 lib/ssh/src/ssh_connection_handler.erl | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl
index 1d9151b..859db8e 100644
--- a/lib/ssh/src/ssh_connection_handler.erl
+++ b/lib/ssh/src/ssh_connection_handler.erl
@@ -1379,8 +1379,8 @@ handle_event(info, {Proto, Sock, NewData}, StateName,
                     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,MaxLogItemLen]),
+                                         io_lib:format("Bad packet: Decrypted, but can't decode~n~p:~p~n~p",
+                                                       [C,E,ST], [{chars_limit, MaxLogItemLen}]),
                                          StateName, D1),
                     {stop, Shutdown, D}
 	    end;
@@ -1414,8 +1414,8 @@ handle_event(info, {Proto, Sock, NewData}, StateName,
             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,MaxLogItemLen]),
+                                 io_lib:format("Bad packet: Couldn't decrypt~n~p:~p~n~p",
+                                               [C,E,ST], [{chars_limit, MaxLogItemLen}]),
                                  StateName, D0),
             {stop, Shutdown, D}
     end;
