- 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
diff --git a/ChangeLog b/ChangeLog
index f78dce6..7e48630 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 0eeb73c..f2ce9de 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 @@
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 @@
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_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