35 lines
1.5 KiB
Diff
35 lines
1.5 KiB
Diff
|
diff -up libssh-0.10.4/include/libssh/sftp.h-cap libssh-0.10.4/include/libssh/sftp.h
|
||
|
--- libssh-0.10.4/include/libssh/sftp.h-cap 2023-09-19 11:28:41.304353437 +0200
|
||
|
+++ libssh-0.10.4/include/libssh/sftp.h 2023-09-19 11:34:20.828666252 +0200
|
||
|
@@ -550,6 +550,10 @@ LIBSSH_API int sftp_async_read(sftp_file
|
||
|
/**
|
||
|
* @brief Write to a file using an opened sftp file handle.
|
||
|
*
|
||
|
+ * The maximum size of the SFTP packet payload is 32768 bytes so the count
|
||
|
+ * parameter is capped at this value. This is low-level function so it does not
|
||
|
+ * try to send more than this amount of data.
|
||
|
+ *
|
||
|
* @param file Open sftp file handle to write to.
|
||
|
*
|
||
|
* @param buf Pointer to buffer to write data.
|
||
|
diff -up libssh-0.10.4/src/sftp.c-cap libssh-0.10.4/src/sftp.c
|
||
|
--- libssh-0.10.4/src/sftp.c-cap 2023-09-19 11:29:02.897569013 +0200
|
||
|
+++ libssh-0.10.4/src/sftp.c 2023-09-19 11:30:36.827506743 +0200
|
||
|
@@ -2179,6 +2179,16 @@ ssize_t sftp_write(sftp_file file, const
|
||
|
|
||
|
id = sftp_get_new_id(file->sftp);
|
||
|
|
||
|
+ /* limit the writes to the maximum specified in Section 3 of
|
||
|
+ * https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-02
|
||
|
+ *
|
||
|
+ * FIXME: This value should be adjusted to the value from the
|
||
|
+ * limits@openssh.com extension if supported
|
||
|
+ * TODO: We should iterate over the blocks rather than writing less than
|
||
|
+ * requested to provide less surprises to the calling applications.
|
||
|
+ */
|
||
|
+ count = count > 32768 ? 32768 : count;
|
||
|
+
|
||
|
rc = ssh_buffer_pack(buffer,
|
||
|
"dSqdP",
|
||
|
id,
|