diff options
author | Hans-Joerg Hoexer <hshoexer@cvs.openbsd.org> | 2004-07-08 19:53:47 +0000 |
---|---|---|
committer | Hans-Joerg Hoexer <hshoexer@cvs.openbsd.org> | 2004-07-08 19:53:47 +0000 |
commit | 2d1da2b1e37039367bc00e4e9f704b6dcc208ed6 (patch) | |
tree | 85eb53c8f84c9927af142f80f9346ed287e6ec57 /sbin/isakmpd | |
parent | 2e419319d8d25e7a9e49ab80864588f9bb90255a (diff) |
free() and close() in error path.
ok ho@
Diffstat (limited to 'sbin/isakmpd')
-rw-r--r-- | sbin/isakmpd/virtual.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sbin/isakmpd/virtual.c b/sbin/isakmpd/virtual.c index d8aff3ad9d4..9f5fdfc9774 100644 --- a/sbin/isakmpd/virtual.c +++ b/sbin/isakmpd/virtual.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtual.c,v 1.4 2004/06/22 03:44:55 ho Exp $ */ +/* $OpenBSD: virtual.c,v 1.5 2004/07/08 19:53:46 hshoexer Exp $ */ /* * Copyright (c) 2004 Håkan Olsson. All rights reserved. @@ -242,13 +242,16 @@ virtual_bind(const struct sockaddr *addr) if (*ep != '\0' || lport < 0 || lport > USHRT_MAX) { log_print("virtual_bind: " "port string \"%s\" not convertible to in_port_t", port); + free(v); return 0; } sockaddr_set_port((struct sockaddr *)&tmp_sa, (in_port_t)lport); v->main = udp_bind((struct sockaddr *)&tmp_sa); - if (!v->main) + if (!v->main) { + free(v); return 0; + } ((struct transport *)v->main)->virtual = (struct transport *)v; #if defined (USE_NAT_TRAVERSAL) @@ -264,13 +267,18 @@ virtual_bind(const struct sockaddr *addr) if (*ep != '\0' || lport < 0 || lport > USHRT_MAX) { log_print("virtual_bind: " "port string \"%s\" not convertible to in_port_t", port); + transport_release(v->main); + free(v); return 0; } sockaddr_set_port((struct sockaddr *)&tmp_sa, (in_port_t)lport); v->encap = udp_encap_bind((struct sockaddr *)&tmp_sa); - if (!v->encap) + if (!v->encap) { + transport_release(v->main); + free(v); return 0; + } ((struct transport *)v->encap)->virtual = (struct transport *)v; #endif v->encap_is_active = 0; @@ -407,6 +415,7 @@ virtual_bind_if(char *ifname, struct sockaddr *if_addr, void *arg) if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&flags_ifr) == -1) { log_error("virtual_bind_if: " "ioctl (%d, SIOCGIFFLAGS, ...) failed", s); + close(s); return -1; } close(s); |