diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2008-07-22 09:45:57 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2008-07-22 09:45:57 +0000 |
commit | b502e7d92bffdd6f0ad0163ef001adcb0b16b3ac (patch) | |
tree | de595e92f0a39256321c0fa89e6bfd6b69361d5f /sbin | |
parent | 9a93d9950346a4fdec15133c3583568f7e8e28a8 (diff) |
If isakmpd is started with -4 or -6, virtual_get_default() may
return NULL. This happens if isakmpd is configured for the other
address family. Add a NULL pointer check and initialize rv.
ok hshoexer
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/isakmpd/udp.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/sbin/isakmpd/udp.c b/sbin/isakmpd/udp.c index be4aac1e7ac..3b46a130a19 100644 --- a/sbin/isakmpd/udp.c +++ b/sbin/isakmpd/udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp.c,v 1.94 2007/04/16 13:01:39 moritz Exp $ */ +/* $OpenBSD: udp.c,v 1.95 2008/07/22 09:45:56 bluhm Exp $ */ /* $EOM: udp.c,v 1.57 2001/01/26 10:09:57 niklas Exp $ */ /* @@ -267,7 +267,7 @@ udp_create(char *name) { struct virtual_transport *v; struct udp_transport *u; - struct transport *rv; + struct transport *rv = 0; struct sockaddr *dst, *addr; char *addr_str, *port_str; struct conf_list *addr_list = 0; @@ -295,18 +295,21 @@ udp_create(char *name) addr_list = conf_get_list("General", "Listen-on"); if (!addr_str && !addr_list) { v = virtual_get_default(dst->sa_family); + if (!v) { + log_print("udp_create: no virtual default transport " + "for address family %d", dst->sa_family); + goto ret; + } u = (struct udp_transport *)v->main; - if (!u) { - log_print("udp_create: no default transport"); - rv = 0; - goto ret; - } else { - rv = udp_clone((struct transport *)u, dst); - if (rv) - rv->vtbl = &udp_transport_vtbl; + log_print("udp_create: no udp default transport " + "for address family %d", dst->sa_family); goto ret; } + rv = udp_clone((struct transport *)u, dst); + if (rv) + rv->vtbl = &udp_transport_vtbl; + goto ret; } if (addr_list) { @@ -323,14 +326,12 @@ udp_create(char *name) } if (!addr_str) { log_print("udp_create: no matching listener found"); - rv = 0; goto ret; } } if (text2sockaddr(addr_str, port_str, &addr, 0, 0)) { log_print("udp_create: address \"%s\" not understood", addr_str); - rv = 0; goto ret; } @@ -339,7 +340,6 @@ udp_create(char *name) if (!v) { log_print("udp_create: %s:%s must exist as a listener too", addr_str, port_str); - rv = 0; goto ret; } rv = udp_clone(v->main, dst); |