]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP: Fix crash when someone deletes our address
authorRoy Marples <roy@marples.name>
Wed, 5 Feb 2025 18:06:01 +0000 (18:06 +0000)
committerRoy Marples <roy@marples.name>
Wed, 12 Feb 2025 11:39:13 +0000 (11:39 +0000)
Fixes #455

src/ipv4.c

index a5fe49009fe3cae56189e7e7614364739e405c90..ce67bfec76ff3d5aeae43762ff1befd409a7a255 100644 (file)
@@ -524,6 +524,7 @@ ipv4_deladdr(struct ipv4_addr *addr, int keeparp)
        struct ipv4_state *state;
        struct ipv4_addr *ap;
 
+       assert(addr != NULL);
        logdebugx("%s: deleting IP address %s",
            addr->iface->name, addr->saddr);
 
@@ -760,7 +761,9 @@ ipv4_applyaddr(void *arg)
                    (DHCPCD_EXITING | DHCPCD_PERSISTENT))
                {
                        if (state->added) {
-                               ipv4_deladdr(state->addr, 0);
+                               /* Someone might have deleted our address */
+                               if (state->addr != NULL)
+                                       ipv4_deladdr(state->addr, 0);
                                rt_build(ifp->ctx, AF_INET);
                        }
                        script_runreason(ifp, state->reason);