c9833c96a4
- use libedit in sftp (#203009) - fixed audit log injection problem (CVE-2007-3102)
72 lines
2.1 KiB
Diff
72 lines
2.1 KiB
Diff
diff -up openssh-4.7p1/sftp-client.c.drain-acks openssh-4.7p1/sftp-client.c
|
|
--- openssh-4.7p1/sftp-client.c.drain-acks 2007-02-19 12:13:39.000000000 +0100
|
|
+++ openssh-4.7p1/sftp-client.c 2007-09-06 17:54:41.000000000 +0200
|
|
@@ -992,7 +992,8 @@ int
|
|
do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
|
|
int pflag)
|
|
{
|
|
- int local_fd, status;
|
|
+ int local_fd;
|
|
+ int status = SSH2_FX_OK;
|
|
u_int handle_len, id, type;
|
|
u_int64_t offset;
|
|
char *handle, *data;
|
|
@@ -1074,7 +1075,7 @@ do_upload(struct sftp_conn *conn, char *
|
|
* Simulate an EOF on interrupt, allowing ACKs from the
|
|
* server to drain.
|
|
*/
|
|
- if (interrupted)
|
|
+ if (interrupted || status != SSH2_FX_OK)
|
|
len = 0;
|
|
else do
|
|
len = read(local_fd, data, conn->transfer_buflen);
|
|
@@ -1131,18 +1132,6 @@ do_upload(struct sftp_conn *conn, char *
|
|
fatal("Can't find request for ID %u", r_id);
|
|
TAILQ_REMOVE(&acks, ack, tq);
|
|
|
|
- if (status != SSH2_FX_OK) {
|
|
- error("Couldn't write to remote file \"%s\": %s",
|
|
- remote_path, fx2txt(status));
|
|
- if (showprogress)
|
|
- stop_progress_meter();
|
|
- do_close(conn, handle, handle_len);
|
|
- close(local_fd);
|
|
- xfree(data);
|
|
- xfree(ack);
|
|
- status = -1;
|
|
- goto done;
|
|
- }
|
|
debug3("In write loop, ack for %u %u bytes at %llu",
|
|
ack->id, ack->len, (unsigned long long)ack->offset);
|
|
++ackid;
|
|
@@ -1154,21 +1143,25 @@ do_upload(struct sftp_conn *conn, char *
|
|
stop_progress_meter();
|
|
xfree(data);
|
|
|
|
+ if (status != SSH2_FX_OK) {
|
|
+ error("Couldn't write to remote file \"%s\": %s",
|
|
+ remote_path, fx2txt(status));
|
|
+ status = -1;
|
|
+ }
|
|
+
|
|
if (close(local_fd) == -1) {
|
|
error("Couldn't close local file \"%s\": %s", local_path,
|
|
strerror(errno));
|
|
- do_close(conn, handle, handle_len);
|
|
status = -1;
|
|
- goto done;
|
|
}
|
|
|
|
/* Override umask and utimes if asked */
|
|
if (pflag)
|
|
do_fsetstat(conn, handle, handle_len, &a);
|
|
|
|
- status = do_close(conn, handle, handle_len);
|
|
+ if (do_close(conn, handle, handle_len) != SSH2_FX_OK)
|
|
+ status = -1;
|
|
|
|
-done:
|
|
xfree(handle);
|
|
buffer_free(&msg);
|
|
return(status);
|