summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbenno <benno@openbsd.org>2020-12-29 19:50:51 +0000
committerbenno <benno@openbsd.org>2020-12-29 19:50:51 +0000
commit61791ef05918de39c9a2c96dca40b54231bb5f8e (patch)
treec1d4391087fa03bfe8e1cbfd6f6530e514299d8a
parentgetifaddrs() can return entries where ifa_addr is NULL. Check for this (diff)
downloadwireguard-openbsd-61791ef05918de39c9a2c96dca40b54231bb5f8e.tar.xz
wireguard-openbsd-61791ef05918de39c9a2c96dca40b54231bb5f8e.zip
getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr. ok claudio@
-rw-r--r--sbin/route/route.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c
index c13f5b6be07..9130b9ff692 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.250 2020/11/25 21:36:05 krw Exp $ */
+/* $OpenBSD: route.c,v 1.251 2020/12/29 19:50:51 benno Exp $ */
/* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */
/*
@@ -506,7 +506,8 @@ setsource(int argc, char **argv)
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
if (if_nametoindex(ifa->ifa_name) != ifindex)
continue;
- if (!(ifa->ifa_addr->sa_family == AF_INET ||
+ if (ifa->ifa_addr == NULL ||
+ !(ifa->ifa_addr->sa_family == AF_INET ||
ifa->ifa_addr->sa_family == AF_INET6))
continue;
if ((af != AF_UNSPEC) &&