From c3b2b4092648e6a133fcc82bd619d7de736921a9 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 2 Jun 2024 17:33:48 +0000 Subject: [PATCH] Make sure we find a link-local address and rdomain pointed out by jsg & miod --- sbin/dhcp6leased/dhcp6leased.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sbin/dhcp6leased/dhcp6leased.c b/sbin/dhcp6leased/dhcp6leased.c index 658be71710f..9d9c4d545b4 100644 --- a/sbin/dhcp6leased/dhcp6leased.c +++ b/sbin/dhcp6leased/dhcp6leased.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcp6leased.c,v 1.4 2024/06/02 15:43:24 florian Exp $ */ +/* $OpenBSD: dhcp6leased.c,v 1.5 2024/06/02 17:33:48 florian Exp $ */ /* * Copyright (c) 2017, 2021, 2024 Florian Obser @@ -750,8 +750,8 @@ void open_udpsock(uint32_t if_index) { struct ifaddrs *ifap, *ifa; - struct sockaddr_in6 *sin6; - int udpsock = -1, rdomain, opt = 1; + struct sockaddr_in6 *sin6 = NULL; + int udpsock = -1, rdomain = -1, opt = 1; char if_name[IF_NAMESIZE]; if (if_indextoname(if_index, if_name) == NULL) { @@ -797,6 +797,18 @@ open_udpsock(uint32_t if_index) } } + if(sin6 == NULL) { + log_warnx("%s: missing link-local address on %s", __func__, + if_name); + goto out; + } + + if(rdomain == -1) { + log_warnx("%s: cannot find rdomain for %s", __func__, + if_name); + goto out; + } + sin6->sin6_port = htons(CLIENT_PORT); log_debug("%s: %s rdomain: %d", __func__, sin6_to_str(sin6), rdomain); -- 2.20.1