summaryrefslogtreecommitdiff
path: root/sftp-client.c
diff options
context:
space:
mode:
Diffstat (limited to 'sftp-client.c')
-rw-r--r--sftp-client.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/sftp-client.c b/sftp-client.c
index caa384b4e..d7eff70b4 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-client.c,v 1.94 2010/12/04 00:18:01 djm Exp $ */ 1/* $OpenBSD: sftp-client.c,v 1.96 2011/09/12 08:46:15 markus 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 *
@@ -462,12 +462,12 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int printflag,
462 buffer_put_cstring(&msg, path); 462 buffer_put_cstring(&msg, path);
463 send_msg(conn, &msg); 463 send_msg(conn, &msg);
464 464
465 buffer_clear(&msg);
466
467 handle = get_handle(conn, id, &handle_len, 465 handle = get_handle(conn, id, &handle_len,
468 "remote readdir(\"%s\")", path); 466 "remote readdir(\"%s\")", path);
469 if (handle == NULL) 467 if (handle == NULL) {
468 buffer_free(&msg);
470 return -1; 469 return -1;
470 }
471 471
472 if (dir) { 472 if (dir) {
473 ents = 0; 473 ents = 0;
@@ -510,6 +510,7 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int printflag,
510 fx2txt(status)); 510 fx2txt(status));
511 do_close(conn, handle, handle_len); 511 do_close(conn, handle, handle_len);
512 xfree(handle); 512 xfree(handle);
513 buffer_free(&msg);
513 return(status); 514 return(status);
514 } 515 }
515 } else if (type != SSH2_FXP_NAME) 516 } else if (type != SSH2_FXP_NAME)
@@ -805,15 +806,15 @@ do_hardlink(struct sftp_conn *conn, char *oldpath, char *newpath)
805 Buffer msg; 806 Buffer msg;
806 u_int status, id; 807 u_int status, id;
807 808
808 buffer_init(&msg);
809
810 /* Send link request */
811 id = conn->msg_id++;
812 if ((conn->exts & SFTP_EXT_HARDLINK) == 0) { 809 if ((conn->exts & SFTP_EXT_HARDLINK) == 0) {
813 error("Server does not support hardlink@openssh.com extension"); 810 error("Server does not support hardlink@openssh.com extension");
814 return -1; 811 return -1;
815 } 812 }
816 813
814 buffer_init(&msg);
815
816 /* Send link request */
817 id = conn->msg_id++;
817 buffer_put_char(&msg, SSH2_FXP_EXTENDED); 818 buffer_put_char(&msg, SSH2_FXP_EXTENDED);
818 buffer_put_int(&msg, id); 819 buffer_put_int(&msg, id);
819 buffer_put_cstring(&msg, "hardlink@openssh.com"); 820 buffer_put_cstring(&msg, "hardlink@openssh.com");
@@ -889,6 +890,7 @@ do_readlink(struct sftp_conn *conn, char *path)
889 u_int status = buffer_get_int(&msg); 890 u_int status = buffer_get_int(&msg);
890 891
891 error("Couldn't readlink: %s", fx2txt(status)); 892 error("Couldn't readlink: %s", fx2txt(status));
893 buffer_free(&msg);
892 return(NULL); 894 return(NULL);
893 } else if (type != SSH2_FXP_NAME) 895 } else if (type != SSH2_FXP_NAME)
894 fatal("Expected SSH2_FXP_NAME(%u) packet, got %u", 896 fatal("Expected SSH2_FXP_NAME(%u) packet, got %u",