diff options
| author | Roy Marples <roy@marples.name> | 2020-09-28 21:10:21 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2020-09-28 21:10:21 +0100 |
| commit | c35a09f0dffba170cb46323b66fce92e2b47256f (patch) | |
| tree | 84923ed43cf02721ebf0c5ff746c96e8dd36a405 | |
| parent | 96702451aea98a8d682ebac5a46e14802e05f624 (diff) | |
| download | dhcpcd-c35a09f0dffba170cb46323b66fce92e2b47256f.tar.xz | |
privsep: fix crash when interface departs before bpf returns for it
| -rw-r--r-- | src/dhcp.c | 3 | ||||
| -rw-r--r-- | src/privsep-bpf.c | 4 |
2 files changed, 7 insertions, 0 deletions
@@ -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) { diff --git a/src/privsep-bpf.c b/src/privsep-bpf.c index f7662333..f8240f12 100644 --- a/src/privsep-bpf.c +++ b/src/privsep-bpf.c @@ -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; |
