summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2024-06-02 17:33:49 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2024-06-02 17:33:49 +0000
commitb7a67f9affe7fb0791e3800dbc541cc199fdab2a (patch)
treecaae4055e9bd6127dea39a149f60ef3d33bbdb2e
parentbc36cab6beca9a3075b9e4399fbae83fdb6161c1 (diff)
Make sure we find a link-local address and rdomain
pointed out by jsg & miod
-rw-r--r--sbin/dhcp6leased/dhcp6leased.c18
1 files 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 <florian@openbsd.org>
@@ -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);