summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2002-04-06 00:30:09 +0000
committerDamien Miller <djm@cvs.openbsd.org>2002-04-06 00:30:09 +0000
commit139deff1122936093e1fd43d9b30850a9c902288 (patch)
treea959c96198a57dbb706f17c9ba1af8f5e9f77857
parentc0fe3476f89e7696f2187889ea4fb09bae034ffc (diff)
Fix occasional corruption on upload due to bad reuse of request id, spotted
by chombier@mac.com; ok markus@
-rw-r--r--usr.bin/ssh/sftp-client.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/ssh/sftp-client.c b/usr.bin/ssh/sftp-client.c
index 7860693c2a3..ff3053e02a2 100644
--- a/usr.bin/ssh/sftp-client.c
+++ b/usr.bin/ssh/sftp-client.c
@@ -28,7 +28,7 @@
/* XXX: copy between two remote sites */
#include "includes.h"
-RCSID("$OpenBSD: sftp-client.c,v 1.30 2002/04/01 22:07:17 markus Exp $");
+RCSID("$OpenBSD: sftp-client.c,v 1.31 2002/04/06 00:30:08 djm Exp $");
#include <sys/queue.h>
@@ -1057,10 +1057,12 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
if (id == startid || len == 0 ||
id - ackid >= conn->num_requests) {
+ u_int r_id;
+
buffer_clear(&msg);
get_msg(conn->fd_in, &msg);
type = buffer_get_char(&msg);
- id = buffer_get_int(&msg);
+ r_id = buffer_get_int(&msg);
if (type != SSH2_FXP_STATUS)
fatal("Expected SSH2_FXP_STATUS(%d) packet, "
@@ -1071,11 +1073,11 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
/* Find the request in our queue */
for(ack = TAILQ_FIRST(&acks);
- ack != NULL && ack->id != id;
+ ack != NULL && ack->id != r_id;
ack = TAILQ_NEXT(ack, tq))
;
if (ack == NULL)
- fatal("Can't find request for ID %d", id);
+ fatal("Can't find request for ID %d", r_id);
TAILQ_REMOVE(&acks, ack, tq);
if (status != SSH2_FX_OK) {