From 3decdba42525170d56755bbdab1997b5004d3b9f Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Thu, 22 Sep 2011 21:41:05 +1000 Subject: - 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 --- sftp-client.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'sftp-client.c') 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 @@ -/* $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 * @@ -805,15 +805,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"); @@ -889,6 +889,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", -- cgit v1.2.3 From 57c38ac7d5e81c9fa6643ec8a3ed08c0c96bde64 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Thu, 22 Sep 2011 21:42:45 +1000 Subject: - markus@cvs.openbsd.org 2011/09/12 08:46:15 [sftp-client.c] fix leak in do_lsreaddir(); ok djm --- ChangeLog | 3 +++ sftp-client.c | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'sftp-client.c') diff --git a/ChangeLog b/ChangeLog index a8846d47a..da9306531 100644 --- a/ChangeLog +++ b/ChangeLog @@ -67,6 +67,9 @@ [sftp-client.c] fix leaks in do_hardlink() and do_readlink(); bz#1921 from Loganaden Velvindron + - markus@cvs.openbsd.org 2011/09/12 08:46:15 + [sftp-client.c] + fix leak in do_lsreaddir(); ok djm 20110909 - (dtucker) [entropy.h] Bug #1932: remove old definition of init_rng. From diff --git a/sftp-client.c b/sftp-client.c index b6d402143..d7eff70b4 100644 --- a/sftp-client.c +++ b/sftp-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp-client.c,v 1.95 2011/09/11 16:07:26 markus Exp $ */ +/* $OpenBSD: sftp-client.c,v 1.96 2011/09/12 08:46:15 markus Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -462,12 +462,12 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int printflag, buffer_put_cstring(&msg, path); send_msg(conn, &msg); - buffer_clear(&msg); - handle = get_handle(conn, id, &handle_len, "remote readdir(\"%s\")", path); - if (handle == NULL) + if (handle == NULL) { + buffer_free(&msg); return -1; + } if (dir) { ents = 0; @@ -510,6 +510,7 @@ do_lsreaddir(struct sftp_conn *conn, char *path, int printflag, fx2txt(status)); do_close(conn, handle, handle_len); xfree(handle); + buffer_free(&msg); return(status); } } else if (type != SSH2_FXP_NAME) -- cgit v1.2.3