File curl-libssh_Implement_SFTP_packet_size_limit.patch of Package curl.33127

From b9c8387c5ae3178d3eb65ad7b9d9683717d5012b Mon Sep 17 00:00:00 2001
From: Jakub Jelen <jjelen@redhat.com>
Date: Tue, 5 Sep 2023 17:33:41 +0200
Subject: [PATCH] libssh: Implement SFTP packet size limit

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
---
 lib/vssh/libssh.c | 5 +++++
 1 file changed, 5 insertions(+)

Index: curl-7.66.0/lib/vssh/libssh.c
===================================================================
--- curl-7.66.0.orig/lib/vssh/libssh.c
+++ curl-7.66.0/lib/vssh/libssh.c
@@ -2389,6 +2389,11 @@ static ssize_t sftp_send(struct connectd
   ssize_t nwrite;
   (void)sockindex;
 
+  /* limit the writes to the maximum specified in Section 3 of
+   * https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02
+   */
+  len = len > 32768 ? 32768 : len;
+
   nwrite = sftp_write(conn->proto.sshc.sftp_file, mem, len);
 
   myssh_block2waitfor(conn, FALSE);
openSUSE Build Service is sponsored by