From 06e9515eb898a335be246759b3059f2e7a4da698 Mon Sep 17 00:00:00 2001 From: Ben Lindstrom Date: Sat, 6 Apr 2002 04:16:45 +0000 Subject: [PATCH] - djm@cvs.openbsd.org 2002/04/06 00:30:08 [sftp-client.c] Fix occasional corruption on upload due to bad reuse of request id, spotted by chombier@mac.com; ok markus@ --- ChangeLog | 8 +++++++- sftp-client.c | 10 ++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67433b8aa..ad22e4485 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,12 @@ - (djm) Typo in Suse SPEC file. Fix from Carsten Grohmann - (bal) Added MAP_FAILED to allow AIX and Trusted HP to compile. + - (bal) OpenBSD CVS Sync + - djm@cvs.openbsd.org 2002/04/06 00:30:08 + [sftp-client.c] + Fix occasional corruption on upload due to bad reuse of request id, spotted + by chombier@mac.com; ok markus@ + 20020405 - (bal) Patch for OpenSC SmartCard library; ok markus@; patch by @@ -8172,4 +8178,4 @@ - Wrote replacements for strlcpy and mkdtemp - Released 1.0pre1 -$Id: ChangeLog,v 1.2027 2002/04/06 04:11:28 mouring Exp $ +$Id: ChangeLog,v 1.2028 2002/04/06 04:16:45 mouring Exp $ diff --git a/sftp-client.c b/sftp-client.c index 9fa8376e6..0d42696ae 100644 --- a/sftp-client.c +++ b/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 "openbsd-compat/fake-queue.h" @@ -1061,10 +1061,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, " @@ -1075,11 +1077,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) {