From ea54190e82662a5c895c614ab2ea0aa4c1ba05dc Mon Sep 17 00:00:00 2001 From: bluhm Date: Tue, 22 Jul 2008 09:45:56 +0000 Subject: [PATCH] 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 --- sbin/isakmpd/udp.c | 26 +++++++++++++------------- 1 file 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); -- 2.20.1