summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorSebastian Benoit <benno@cvs.openbsd.org>2020-12-30 18:41:34 +0000
committerSebastian Benoit <benno@cvs.openbsd.org>2020-12-30 18:41:34 +0000
commit782536f481b54056f1383336a1f94a8f37012af9 (patch)
tree07738e6f77abeb6924113049a4e197fed98b22b5 /usr.sbin
parent5b48b437dfb875dac217981de7232ff2142e221d (diff)
getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr. ok claudio@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/eigrpd/parse.y5
-rw-r--r--usr.sbin/httpd/parse.y5
-rw-r--r--usr.sbin/ifstated/ifstated.c5
-rw-r--r--usr.sbin/inetd/inetd.c5
-rw-r--r--usr.sbin/ldapd/parse.y4
5 files changed, 15 insertions, 9 deletions
diff --git a/usr.sbin/eigrpd/parse.y b/usr.sbin/eigrpd/parse.y
index f024e3cf0cd..02b0bcc31f2 100644
--- a/usr.sbin/eigrpd/parse.y
+++ b/usr.sbin/eigrpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.30 2019/02/13 22:57:08 deraadt Exp $ */
+/* $OpenBSD: parse.y,v 1.31 2020/12/30 18:39:57 benno Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -1246,7 +1246,8 @@ get_rtr_id(void)
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
if (strncmp(ifa->ifa_name, "carp", 4) == 0)
continue;
- if (ifa->ifa_addr->sa_family != AF_INET)
+ if (ifa->ifa_addr == NULL ||
+ ifa->ifa_addr->sa_family != AF_INET)
continue;
cur = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr;
if ((cur & localnet) == localnet) /* skip 127/8 */
diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y
index b3c8786aaee..45eaa1ab003 100644
--- a/usr.sbin/httpd/parse.y
+++ b/usr.sbin/httpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.121 2020/11/20 20:39:31 jung Exp $ */
+/* $OpenBSD: parse.y,v 1.122 2020/12/30 18:40:22 benno Exp $ */
/*
* Copyright (c) 2020 Matthias Pressfreund <mpfr@fn.de>
@@ -2124,7 +2124,8 @@ host_if(const char *s, struct addresslist *al, int max,
nextaf:
for (p = ifap; p != NULL && cnt < max; p = p->ifa_next) {
- if (p->ifa_addr->sa_family != af ||
+ if (p->ifa_addr == NULL ||
+ p->ifa_addr->sa_family != af ||
(strcmp(s, p->ifa_name) != 0 &&
!is_if_in_group(p->ifa_name, s)))
continue;
diff --git a/usr.sbin/ifstated/ifstated.c b/usr.sbin/ifstated/ifstated.c
index 225f5aaa9e0..7d6ba2fae07 100644
--- a/usr.sbin/ifstated/ifstated.c
+++ b/usr.sbin/ifstated/ifstated.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifstated.c,v 1.64 2019/06/28 13:32:47 deraadt Exp $ */
+/* $OpenBSD: ifstated.c,v 1.65 2020/12/30 18:40:44 benno Exp $ */
/*
* Copyright (c) 2004 Marco Pfatschbacher <mpf@openbsd.org>
@@ -642,7 +642,8 @@ fetch_ifstate(int do_eval)
fatal("getifaddrs");
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
- if (ifa->ifa_addr->sa_family == AF_LINK) {
+ if (ifa->ifa_addr != NULL &&
+ ifa->ifa_addr->sa_family == AF_LINK) {
struct if_data *ifdata = ifa->ifa_data;
scan_ifstate(ifa->ifa_name, ifdata->ifi_link_state,
do_eval);
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c
index 4627ef81148..2c623ef66d1 100644
--- a/usr.sbin/inetd/inetd.c
+++ b/usr.sbin/inetd/inetd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inetd.c,v 1.161 2019/06/28 13:32:48 deraadt Exp $ */
+/* $OpenBSD: inetd.c,v 1.162 2020/12/30 18:41:06 benno Exp $ */
/*
* Copyright (c) 1983,1991 The Regents of the University of California.
@@ -487,7 +487,8 @@ dg_broadcast(struct in_addr *in)
if (getifaddrs(&ifap) == -1)
return (0);
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
- if (ifa->ifa_addr->sa_family != AF_INET ||
+ if (ifa->ifa_addr == NULL ||
+ ifa->ifa_addr->sa_family != AF_INET ||
(ifa->ifa_flags & IFF_BROADCAST) == 0)
continue;
sin = (struct sockaddr_in *)ifa->ifa_broadaddr;
diff --git a/usr.sbin/ldapd/parse.y b/usr.sbin/ldapd/parse.y
index c003b3fcb6a..afe09d947b6 100644
--- a/usr.sbin/ldapd/parse.y
+++ b/usr.sbin/ldapd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.37 2020/11/29 19:48:35 tb Exp $ */
+/* $OpenBSD: parse.y,v 1.38 2020/12/30 18:41:33 benno Exp $ */
/*
* Copyright (c) 2009, 2010 Martin Hedenfalk <martinh@openbsd.org>
@@ -1122,6 +1122,8 @@ interface(const char *s, const char *cert,
for (p = ifap; p != NULL; p = p->ifa_next) {
if (strcmp(s, p->ifa_name) != 0)
continue;
+ if (p->ifa_addr == NULL)
+ continue;
switch (p->ifa_addr->sa_family) {
case AF_INET: