summaryrefslogtreecommitdiff
path: root/usr.bin/ssh
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2013-08-09 03:39:14 +0000
committerDamien Miller <djm@cvs.openbsd.org>2013-08-09 03:39:14 +0000
commit31b3cc7b0caec28250a0a308bfb5f9c57b935bbd (patch)
tree2effc87edd57c41010b8e472c8f51219e55bcb14 /usr.bin/ssh
parentf91c105009048049e7cc0830c2c06c44839d51de (diff)
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
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r--usr.bin/ssh/sftp-client.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/ssh/sftp-client.c b/usr.bin/ssh/sftp-client.c
index c905d8f5e29..6a48aba885c 100644
--- a/usr.bin/ssh/sftp-client.c
+++ b/usr.bin/ssh/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>
*
@@ -330,7 +330,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;
@@ -1214,6 +1215,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,
@@ -1222,7 +1224,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 */
if (pflag && fchmod(local_fd, mode) == -1)