comparison svr-agentfwd.c @ 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 810dfc792ca9
children 220f55d540ae
comparison
equal deleted inserted replaced
616:ae1df0cc3f18 617:81def6b732c7
48 static void agentaccept(struct Listener * listener, int sock); 48 static void agentaccept(struct Listener * listener, int sock);
49 49
50 /* Handles client requests to start agent forwarding, sets up listening socket. 50 /* Handles client requests to start agent forwarding, sets up listening socket.
51 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ 51 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
52 int svr_agentreq(struct ChanSess * chansess) { 52 int svr_agentreq(struct ChanSess * chansess) {
53 53 int fd = -1;
54 int fd;
55
56 TRACE(("enter svr_agentreq"))
57 54
58 if (!svr_pubkey_allows_agentfwd()) { 55 if (!svr_pubkey_allows_agentfwd()) {
59 return DROPBEAR_FAILURE; 56 return DROPBEAR_FAILURE;
60 } 57 }
61 58
89 if (chansess->agentlistener == NULL) { 86 if (chansess->agentlistener == NULL) {
90 goto fail; 87 goto fail;
91 } 88 }
92 89
93 return DROPBEAR_SUCCESS; 90 return DROPBEAR_SUCCESS;
94 TRACE(("success"))
95 91
96 fail: 92 fail:
97 TRACE(("fail")) 93 m_close(fd);
98 /* cleanup */ 94 /* cleanup */
99 svr_agentcleanup(chansess); 95 svr_agentcleanup(chansess);
100 96
101 return DROPBEAR_FAILURE; 97 return DROPBEAR_FAILURE;
102 } 98 }