]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix crash when creating routes for a non preferred lease.
authorRoy Marples <roy@marples.name>
Sat, 24 Jun 2017 16:36:12 +0000 (17:36 +0100)
committerRoy Marples <roy@marples.name>
Wed, 28 Jun 2017 23:03:04 +0000 (00:03 +0100)
Summary:
When dhcpcd shares the same IP address across interfaces, the
non preferred leases have the address deleted but remain in
the BOUND state.
We need to check that the address has been added, otherwise
we crash when building some routes.

Thanks to Jason A. Donenfeld <Jason@zx2c4.com> for the report.

Test Plan:
Ensure the lowest metric interface is denied in denyinterfaces.
Setup your DHCP server to share the same IP addres to all the host interfaces.
Start dhcpcd.
Activate the denied interface via `dhcpcd -n $interface`.
dhcpcd should not crash when binding the routes.

Tags: #dhcpcd

Differential Revision: https://dev.marples.name/D121

src/ipv4.c

index 224e8abf686d43b82b5bb52e10721d97d18ac546..b8ce222af6377fbb012e2f037fd792a63b181c47 100644 (file)
@@ -255,9 +255,12 @@ inet_dhcproutes(struct rt_head *routes, struct interface *ifp)
        int n;
 
        state = D_CSTATE(ifp);
-       if (state == NULL || state->state != DHS_BOUND)
+       if (state == NULL || state->state != DHS_BOUND || !state->added)
                return 0;
 
+       /* An address does have to exist. */
+       assert(state->addr);
+
        TAILQ_INIT(&nroutes);
 
        /* First, add a subnet route. */