summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-09-28 21:10:21 +0100
committerRoy Marples <roy@marples.name>2020-09-28 21:10:21 +0100
commitc35a09f0dffba170cb46323b66fce92e2b47256f (patch)
tree84923ed43cf02721ebf0c5ff746c96e8dd36a405
parent96702451aea98a8d682ebac5a46e14802e05f624 (diff)
downloaddhcpcd-c35a09f0dffba170cb46323b66fce92e2b47256f.tar.xz
privsep: fix crash when interface departs before bpf returns for it
-rw-r--r--src/dhcp.c3
-rw-r--r--src/privsep-bpf.c4
2 files changed, 7 insertions, 0 deletions
diff --git a/src/dhcp.c b/src/dhcp.c
index 61cc256a..923c5af5 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -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;