summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2011-09-11 16:07:27 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2011-09-11 16:07:27 +0000
commit1e08871b64c4e160947cdbadbcd5b2e490584241 (patch)
treef071b40576219f74b8d79751f35be38ae6a87713 /usr.bin
parent191fe9f7df88c237c0ff7536f3ba434ba2718a32 (diff)
fix leaks in do_hardlink() and do_readlink(); bz#1921
from Loganaden Velvindron
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/sftp-client.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/ssh/sftp-client.c b/usr.bin/ssh/sftp-client.c
index 42979bbd493..ff9f29c27c5 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.94 2010/12/04 00:18:01 djm Exp $ */
+/* $OpenBSD: sftp-client.c,v 1.95 2011/09/11 16:07:26 markus Exp $ */
/*
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
*
@@ -798,15 +798,15 @@ do_hardlink(struct sftp_conn *conn, char *oldpath, char *newpath)
Buffer msg;
u_int status, id;
- buffer_init(&msg);
-
- /* Send link request */
- id = conn->msg_id++;
if ((conn->exts & SFTP_EXT_HARDLINK) == 0) {
error("Server does not support hardlink@openssh.com extension");
return -1;
}
+ buffer_init(&msg);
+
+ /* Send link request */
+ id = conn->msg_id++;
buffer_put_char(&msg, SSH2_FXP_EXTENDED);
buffer_put_int(&msg, id);
buffer_put_cstring(&msg, "hardlink@openssh.com");
@@ -882,6 +882,7 @@ do_readlink(struct sftp_conn *conn, char *path)
u_int status = buffer_get_int(&msg);
error("Couldn't readlink: %s", fx2txt(status));
+ buffer_free(&msg);
return(NULL);
} else if (type != SSH2_FXP_NAME)
fatal("Expected SSH2_FXP_NAME(%u) packet, got %u",