File 1021-Limit-buffer-and-packet_size-instead-of-recbuf-for-h.patch of Package erlang
From 8121e3a785a855624071ffc897979cff4d132b45 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20W=C4=85sowski?= <michal@erlang.org>
Date: Thu, 6 Nov 2025 10:10:13 +0100
Subject: [PATCH] Limit buffer and packet_size instead of recbuf for hello
message
---
lib/ssh/src/ssh_connection_handler.erl | 14 ++++++++------
lib/ssh/src/ssh_fsm.hrl | 2 +-
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl
index 2648c5256b..0521bc7dcc 100644
--- a/lib/ssh/src/ssh_connection_handler.erl
+++ b/lib/ssh/src/ssh_connection_handler.erl
@@ -592,17 +592,18 @@ handle_event(cast, socket_control, {wait_for_socket, Role},
handle_event(internal, socket_ready, {hello,_}=StateName, #data{ssh_params = Ssh0} = D) ->
VsnMsg = ssh_transport:hello_version_msg(string_version(Ssh0)),
send_bytes(VsnMsg, D),
- case inet:getopts(Socket=D#data.socket, [recbuf]) of
- {ok, [{recbuf,Size}]} ->
+ case inet:getopts(Socket=D#data.socket, [buffer]) of
+ {ok, [{buffer,Size}]} ->
%% Set the socket to the hello text line handling mode:
inet:setopts(Socket, [{packet, line},
{active, once},
% Expecting the version string which might
% be max ?MAX_PROTO_VERSION bytes:
- {recbuf, ?MAX_PROTO_VERSION},
+ {buffer, ?MAX_PROTO_VERSION},
+ {packet_size, ?MAX_PROTO_VERSION},
{nodelay,true}]),
Time = ?GET_OPT(hello_timeout, Ssh0#ssh.opts, infinity),
- {keep_state, D#data{inet_initial_recbuf_size=Size}, [{state_timeout,Time,no_hello_received}] };
+ {keep_state, D#data{inet_initial_buffer_size=Size}, [{state_timeout,Time,no_hello_received}] };
Other ->
?call_disconnectfun_and_log_cond("Option return",
@@ -631,11 +632,12 @@ handle_event(internal, {version_exchange,Version}, {hello,Role}, D0) ->
case handle_version(NumVsn, StrVsn, D0#data.ssh_params) of
{ok, Ssh1} ->
%% Since the hello part is finished correctly, we set the
- %% socket to the packet handling mode (including recbuf size):
+ %% socket to the packet handling mode (including buffer size):
inet:setopts(D0#data.socket, [{packet,0},
{mode,binary},
{active, once},
- {recbuf, D0#data.inet_initial_recbuf_size}]),
+ {buffer, D0#data.inet_initial_buffer_size},
+ {packet_size, 0}]),
{KeyInitMsg, SshPacket, Ssh} = ssh_transport:key_exchange_init_msg(Ssh1),
send_bytes(SshPacket, D0),
D = D0#data{ssh_params = Ssh,
diff --git a/lib/ssh/src/ssh_fsm.hrl b/lib/ssh/src/ssh_fsm.hrl
index 917a8fb1d4..07d5b9e3bb 100644
--- a/lib/ssh/src/ssh_fsm.hrl
+++ b/lib/ssh/src/ssh_fsm.hrl
@@ -37,7 +37,7 @@
| undefined,
last_size_rekey = 0 :: non_neg_integer(),
event_queue = [] :: list(),
- inet_initial_recbuf_size :: pos_integer()
+ inet_initial_buffer_size :: pos_integer()
| undefined
}).
--
2.51.0