From: Roy Marples Date: Sat, 24 Jun 2017 16:36:12 +0000 (+0100) Subject: Fix crash when creating routes for a non preferred lease. X-Git-Tag: v7.0.0-rc2~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5efbd5a5bfdd3be9b0d829c2889bb2d6bf3cfd1e;p=thirdparty%2Fdhcpcd.git Fix crash when creating routes for a non preferred lease. 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 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 --- diff --git a/src/ipv4.c b/src/ipv4.c index 224e8abf..b8ce222a 100644 --- a/src/ipv4.c +++ b/src/ipv4.c @@ -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. */