FW: can function sftp_upload return OK even if an error message is received?
Damien Miller
djm at mindrot.org
Tue Sep 30 09:25:23 AEST 2025
On Fri, 19 Sep 2025, Graziano Stefani (Nokia) via openssh-unix-dev wrote:
> Hi,
>
> Were there any conclusions on this subject? Can the proposed
> fix (introducing variable status_2 to save the error in the
> SSH2_FXP_STATUS message) be acceptable?
> - debug3("SSH2_FXP_STATUS %u", status);
> + debug3("SSH2_FXP_STATUS %u", status_2);
> + if (status == SSH2_FX_OK)
> + status = status_2;
I think this patch is wrong. The condition should be != SSH2_FX_OK,
otherwise the error is never stored.
diff --git a/sftp-client.c b/sftp-client.c
index 0993291..004cbe3 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -2018,7 +2018,7 @@ sftp_upload(struct sftp_conn *conn, const char *local_path,
int fsync_flag, int inplace_flag)
{
int r, local_fd;
- u_int openmode, id, status = SSH2_FX_OK, reordered = 0;
+ u_int openmode, id, status = SSH2_FX_OK, status2, reordered = 0;
off_t offset, progress_counter;
u_char type, *handle, *data;
struct sshbuf *msg;
@@ -2155,9 +2155,11 @@ sftp_upload(struct sftp_conn *conn, const char *local_path,
fatal("Expected SSH2_FXP_STATUS(%d) packet, "
"got %d", SSH2_FXP_STATUS, type);
- if ((r = sshbuf_get_u32(msg, &status)) != 0)
+ if ((r = sshbuf_get_u32(msg, &status2)) != 0)
fatal_fr(r, "parse status");
- debug3("SSH2_FXP_STATUS %u", status);
+ debug3("SSH2_FXP_STATUS %u", status2);
+ if (status2 != SSH2_FX_OK)
+ status = status2; /* remember errors */
/* Find the request in our queue */
if ((ack = request_find(&acks, rid)) == NULL)
More information about the openssh-unix-dev
mailing list