]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
privsep: fix crash when interface departs before bpf returns for it
authorRoy Marples <roy@marples.name>
Mon, 28 Sep 2020 20:10:21 +0000 (21:10 +0100)
committerRoy Marples <roy@marples.name>
Mon, 28 Sep 2020 20:10:21 +0000 (21:10 +0100)
src/dhcp.c
src/privsep-bpf.c

index 61cc256a85969b05a452dda7b9760d75cabf7e5d..923c5af5cc3a342f8c50001200b097a7c68c2ae1 100644 (file)
@@ -3477,6 +3477,9 @@ dhcp_packet(struct interface *ifp, uint8_t *data, size_t len,
 #ifdef PRIVSEP
        const struct dhcp_state *state = D_CSTATE(ifp);
 
+       if (state == NULL)
+               return;
+
        /* Ignore double reads */
        if (IN_PRIVSEP(ifp->ctx)) {
                switch (state->state) {
index f76623339533e964b2013e329733d8f2fb5a4996..f8240f12a349cf155f9ed5c08ab781ad87817ee2 100644 (file)
@@ -266,6 +266,10 @@ ps_bpf_dispatch(struct dhcpcd_ctx *ctx,
        size_t bpf_len;
 
        ifp = if_findindex(ctx->ifaces, psm->ps_id.psi_ifindex);
+       /* interface may have departed .... */
+       if (ifp == NULL)
+               return -1;
+
        bpf = iov->iov_base;
        bpf_len = iov->iov_len;