diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-11-18 18:42:55 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-11-18 18:42:55 +0000 |
commit | d25b36fc3db0e51027f2a176022d8ff6dba92df5 (patch) | |
tree | 1bf13ca15e7e62a7e9c60d67853b7bd148cde47b | |
parent | 8248dbc97d416cd7e047cc4fb8ed2e1bb189a459 (diff) |
Recognize get_link_ifa() failure (a.k.a. "invalid interface") as a fatal error
in interface_state() as it is elsewhere.
Avoids any possible NULL pointer dereference.
-rw-r--r-- | sbin/dhclient/dhclient.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index ec5b5f0ccb2..315a04cc3de 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.680 2020/11/18 17:43:33 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.681 2020/11/18 18:42:54 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -251,8 +251,10 @@ interface_state(struct interface_info *ifi) fatal("getifaddrs"); ifa = get_link_ifa(ifi->name, ifap); - if (ifa == NULL || - (ifa->ifa_flags & IFF_UP) == 0 || + if (ifa == NULL) + fatalx("invalid interface"); + + if ((ifa->ifa_flags & IFF_UP) == 0 || (ifa->ifa_flags & IFF_RUNNING) == 0) { ifi->link_state = LINK_STATE_DOWN; } else { |