summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2011-09-22 21:41:05 +1000
committerDamien Miller <djm@mindrot.org>2011-09-22 21:41:05 +1000
commit3decdba42525170d56755bbdab1997b5004d3b9f (patch)
tree7a04624c8f0f0e757113b5dd4d992ce4d76e2c36
parent1bcbd0a9de64b3c633e2293c74c750908aac2af4 (diff)
- markus@cvs.openbsd.org 2011/09/11 16:07:26
[sftp-client.c] fix leaks in do_hardlink() and do_readlink(); bz#1921 from Loganaden Velvindron
-rw-r--r--ChangeLog4
-rw-r--r--sftp-client.c11
2 files changed, 10 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index f4baa4ebe..a8846d47a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -63,6 +63,10 @@
63 - okan@cvs.openbsd.org 2011/09/11 06:59:05 63 - okan@cvs.openbsd.org 2011/09/11 06:59:05
64 [ssh.1] 64 [ssh.1]
65 document new -O cancel command; ok djm@ 65 document new -O cancel command; ok djm@
66 - markus@cvs.openbsd.org 2011/09/11 16:07:26
67 [sftp-client.c]
68 fix leaks in do_hardlink() and do_readlink(); bz#1921
69 from Loganaden Velvindron
66 70
6720110909 7120110909
68 - (dtucker) [entropy.h] Bug #1932: remove old definition of init_rng. From 72 - (dtucker) [entropy.h] Bug #1932: remove old definition of init_rng. From
diff --git a/sftp-client.c b/sftp-client.c
index caa384b4e..b6d402143 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.95 2011/09/11 16:07:26 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 *
@@ -805,15 +805,15 @@ do_hardlink(struct sftp_conn *conn, char *oldpath, char *newpath)
805 Buffer msg; 805 Buffer msg;
806 u_int status, id; 806 u_int status, id;
807 807
808 buffer_init(&msg);
809
810 /* Send link request */
811 id = conn->msg_id++;
812 if ((conn->exts & SFTP_EXT_HARDLINK) == 0) { 808 if ((conn->exts & SFTP_EXT_HARDLINK) == 0) {
813 error("Server does not support hardlink@openssh.com extension"); 809 error("Server does not support hardlink@openssh.com extension");
814 return -1; 810 return -1;
815 } 811 }
816 812
813 buffer_init(&msg);
814
815 /* Send link request */
816 id = conn->msg_id++;
817 buffer_put_char(&msg, SSH2_FXP_EXTENDED); 817 buffer_put_char(&msg, SSH2_FXP_EXTENDED);
818 buffer_put_int(&msg, id); 818 buffer_put_int(&msg, id);
819 buffer_put_cstring(&msg, "hardlink@openssh.com"); 819 buffer_put_cstring(&msg, "hardlink@openssh.com");
@@ -889,6 +889,7 @@ do_readlink(struct sftp_conn *conn, char *path)
889 u_int status = buffer_get_int(&msg); 889 u_int status = buffer_get_int(&msg);
890 890
891 error("Couldn't readlink: %s", fx2txt(status)); 891 error("Couldn't readlink: %s", fx2txt(status));
892 buffer_free(&msg);
892 return(NULL); 893 return(NULL);
893 } else if (type != SSH2_FXP_NAME) 894 } else if (type != SSH2_FXP_NAME)
894 fatal("Expected SSH2_FXP_NAME(%u) packet, got %u", 895 fatal("Expected SSH2_FXP_NAME(%u) packet, got %u",