diff options
author | Sebastian Benoit <benno@cvs.openbsd.org> | 2020-12-30 18:57:29 +0000 |
---|---|---|
committer | Sebastian Benoit <benno@cvs.openbsd.org> | 2020-12-30 18:57:29 +0000 |
commit | 861c66e334fb96b017f25eb6d5d1fb3fb2ff7cd8 (patch) | |
tree | ea4d303ae6173486470402043631aae7fd2b9145 /lib | |
parent | 20400879b5bbfe95497866f44998e6dbe0324688 (diff) |
getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/rpc/get_myaddress.c | 3 | ||||
-rw-r--r-- | lib/libc/rpc/pmap_rmt.c | 8 |
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/libc/rpc/get_myaddress.c b/lib/libc/rpc/get_myaddress.c index d0ac78f796e..99c0dabee70 100644 --- a/lib/libc/rpc/get_myaddress.c +++ b/lib/libc/rpc/get_myaddress.c @@ -1,4 +1,4 @@ -/* $OpenBSD: get_myaddress.c,v 1.15 2015/09/13 15:36:56 guenther Exp $ */ +/* $OpenBSD: get_myaddress.c,v 1.16 2020/12/30 18:56:35 benno Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -67,6 +67,7 @@ get_myaddress(struct sockaddr_in *addr) again: for (ifa = ifap; ifa; ifa = ifa->ifa_next) { if ((ifa->ifa_flags & IFF_UP) && + ifa->ifa_addr != NULL && ifa->ifa_addr->sa_family == AF_INET && (loopback == 1 && (ifa->ifa_flags & IFF_LOOPBACK))) { *addr = *((struct sockaddr_in *)ifa->ifa_addr); diff --git a/lib/libc/rpc/pmap_rmt.c b/lib/libc/rpc/pmap_rmt.c index 097999b5ae6..7d971f690a1 100644 --- a/lib/libc/rpc/pmap_rmt.c +++ b/lib/libc/rpc/pmap_rmt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap_rmt.c,v 1.35 2019/06/28 13:32:42 deraadt Exp $ */ +/* $OpenBSD: pmap_rmt.c,v 1.36 2020/12/30 18:56:35 benno Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -163,7 +163,8 @@ newgetbroadcastnets(struct in_addr **addrsp) 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) continue; if ((ifa->ifa_flags & IFF_BROADCAST) && (ifa->ifa_flags & IFF_UP) && @@ -180,7 +181,8 @@ newgetbroadcastnets(struct in_addr **addrsp) } 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) continue; if ((ifa->ifa_flags & IFF_BROADCAST) && (ifa->ifa_flags & IFF_UP) && |