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);