changeset 617:81def6b732c7

Clean up fd on failure. Found by Klocwork
author Matt Johnston <matt@ucc.asn.au>
date Thu, 07 Apr 2011 13:25:00 +0000
parents ae1df0cc3f18
children b5cc8878d5ec
files svr-agentfwd.c
diffstat 1 files changed, 2 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/svr-agentfwd.c	Thu Apr 07 13:24:41 2011 +0000
+++ b/svr-agentfwd.c	Thu Apr 07 13:25:00 2011 +0000
@@ -50,10 +50,7 @@
 /* Handles client requests to start agent forwarding, sets up listening socket.
  * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
 int svr_agentreq(struct ChanSess * chansess) {
-
-	int fd;
-
-	TRACE(("enter svr_agentreq"))
+	int fd = -1;
 
 	if (!svr_pubkey_allows_agentfwd()) {
 		return DROPBEAR_FAILURE;
@@ -91,10 +88,9 @@
 	}
 
 	return DROPBEAR_SUCCESS;
-	TRACE(("success"))
 
 fail:
-	TRACE(("fail"))
+	m_close(fd);
 	/* cleanup */
 	svr_agentcleanup(chansess);