From 1a655aee4ec07c7fbeb151d91876ed6e32a6ed57 Mon Sep 17 00:00:00 2001 From: Eshan Kelkar Date: Sat, 24 May 2025 02:28:01 +0530 Subject: [PATCH] libssh: Remove write limit capping for newer libssh versions. Since version 0.11.0, libssh has started applying read/write length capping appropriately for both its sync and async API. The limit applied by libssh would be as per what the server imposes if the server supports sharing this info, otherwise the limits would be according to the protocol specified minimum limit that the servers should support. Hence, the calling code does not need to bother applying these limits as per the sftp protocol (libssh's newer versions since 0.11.0 would handle that) Signed-off-by: Eshan Kelkar --- lib/vssh/libssh.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index e5b8de6017..bcdc30eb1e 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -3030,11 +3030,6 @@ static CURLcode sftp_send(struct Curl_easy *data, int sockindex, if(!sshc) return CURLE_FAILED_INIT; - /* limit the writes to the maximum specified in Section 3 of - * https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02 - */ - if(len > 32768) - len = 32768; #if LIBSSH_VERSION_INT > SSH_VERSION_INT(0, 11, 0) switch(sshc->sftp_send_state) { case 0: @@ -3067,6 +3062,17 @@ static CURLcode sftp_send(struct Curl_easy *data, int sockindex, return CURLE_SEND_ERROR; } #else + /* + * limit the writes to the maximum specified in Section 3 of + * https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02 + * + * libssh started applying appropriate read/write length limits + * internally since version 0.11.0, hence such an operation is + * not needed for versions after (and including) 0.11.0. + */ + if(len > 32768) + len = 32768; + nwrite = sftp_write(sshc->sftp_file, mem, len); myssh_block2waitfor(conn, sshc, FALSE);