summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2013-08-21 02:42:12 +1000
committerDamien Miller <djm@mindrot.org>2013-08-21 02:42:12 +1000
commitfec029f1dc2c338f3fae3fa82aabc988dc07868c (patch)
tree96f72e1caaf5e221054c53171c511fc2811cb0a3
parent036d30743fc914089f9849ca52d615891d47e616 (diff)
- djm@cvs.openbsd.org 2013/08/09 03:39:13
[sftp-client.c] two problems found by a to-be-committed regress test: 1) msg_id was not being initialised so was starting at a random value from the heap (harmless, but confusing). 2) some error conditions were not being propagated back to the caller
-rw-r--r--ChangeLog6
-rw-r--r--sftp-client.c8
2 files changed, 11 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index f78dce6e..7e486302 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,6 +30,12 @@
[sftp.c]
do getopt parsing for all sftp commands (with an empty optstring for
commands without arguments) to ensure consistent behaviour
+ - djm@cvs.openbsd.org 2013/08/09 03:39:13
+ [sftp-client.c]
+ two problems found by a to-be-committed regress test: 1) msg_id was not
+ being initialised so was starting at a random value from the heap
+ (harmless, but confusing). 2) some error conditions were not being
+ propagated back to the caller
20130808
- (dtucker) [regress/Makefile regress/test-exec.sh] Don't try to use test -nt
diff --git a/sftp-client.c b/sftp-client.c
index 0eeb73c8..f2ce9deb 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp-client.c,v 1.102 2013/08/08 05:04:03 djm Exp $ */
+/* $OpenBSD: sftp-client.c,v 1.103 2013/08/09 03:39:13 djm Exp $ */
/*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
*
@@ -337,7 +337,8 @@ do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests,
Buffer msg;
struct sftp_conn *ret;
- ret = xmalloc(sizeof(*ret));
+ ret = xcalloc(1, sizeof(*ret));
+ ret->msg_id = 1;
ret->fd_in = fd_in;
ret->fd_out = fd_out;
ret->transfer_buflen = transfer_buflen;
@@ -1221,6 +1222,7 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
if (read_error) {
error("Couldn't read from remote file \"%s\" : %s",
remote_path, fx2txt(status));
+ status = -1;
do_close(conn, handle, handle_len);
} else if (write_error) {
error("Couldn't write to \"%s\": %s", local_path,
@@ -1229,7 +1231,7 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
do_close(conn, handle, handle_len);
} else {
status = do_close(conn, handle, handle_len);
- if (interrupted)
+ if (interrupted || status != SSH2_FX_OK)
status = -1;
/* Override umask and utimes if asked */
#ifdef HAVE_FCHMOD