summaryrefslogtreecommitdiff
path: root/sftp-client.c
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 /sftp-client.c
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
Diffstat (limited to 'sftp-client.c')
-rw-r--r--sftp-client.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sftp-client.c b/sftp-client.c
index 0eeb73c8b..f2ce9deb7 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-client.c,v 1.102 2013/08/08 05:04:03 djm Exp $ */ 1/* $OpenBSD: sftp-client.c,v 1.103 2013/08/09 03:39:13 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -337,7 +337,8 @@ do_init(int fd_in, int fd_out, u_int transfer_buflen, u_int num_requests,
337 Buffer msg; 337 Buffer msg;
338 struct sftp_conn *ret; 338 struct sftp_conn *ret;
339 339
340 ret = xmalloc(sizeof(*ret)); 340 ret = xcalloc(1, sizeof(*ret));
341 ret->msg_id = 1;
341 ret->fd_in = fd_in; 342 ret->fd_in = fd_in;
342 ret->fd_out = fd_out; 343 ret->fd_out = fd_out;
343 ret->transfer_buflen = transfer_buflen; 344 ret->transfer_buflen = transfer_buflen;
@@ -1221,6 +1222,7 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path,
1221 if (read_error) { 1222 if (read_error) {
1222 error("Couldn't read from remote file \"%s\" : %s", 1223 error("Couldn't read from remote file \"%s\" : %s",
1223 remote_path, fx2txt(status)); 1224 remote_path, fx2txt(status));
1225 status = -1;
1224 do_close(conn, handle, handle_len); 1226 do_close(conn, handle, handle_len);
1225 } else if (write_error) { 1227 } else if (write_error) {
1226 error("Couldn't write to \"%s\": %s", local_path, 1228 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,
1229 do_close(conn, handle, handle_len); 1231 do_close(conn, handle, handle_len);
1230 } else { 1232 } else {
1231 status = do_close(conn, handle, handle_len); 1233 status = do_close(conn, handle, handle_len);
1232 if (interrupted) 1234 if (interrupted || status != SSH2_FX_OK)
1233 status = -1; 1235 status = -1;
1234 /* Override umask and utimes if asked */ 1236 /* Override umask and utimes if asked */
1235#ifdef HAVE_FCHMOD 1237#ifdef HAVE_FCHMOD