Mercurial > hg > dhcpcd
changeset 5487:23f35ea1a34a draft
privsep: fix crash when interface departs before bpf returns for it
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Mon, 28 Sep 2020 21:10:21 +0100 |
| parents | 8e2b8ce8c972 |
| children | 1712c2fd62a4 |
| files | src/dhcp.c src/privsep-bpf.c |
| diffstat | 2 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dhcp.c Mon Sep 28 17:09:38 2020 +0100 +++ b/src/dhcp.c Mon Sep 28 21:10:21 2020 +0100 @@ -3477,6 +3477,9 @@ #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) {
--- a/src/privsep-bpf.c Mon Sep 28 17:09:38 2020 +0100 +++ b/src/privsep-bpf.c Mon Sep 28 21:10:21 2020 +0100 @@ -266,6 +266,10 @@ 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;
