]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
privsep: Ensure command is for BPF first and interface valid second
authorRoy Marples <roy@marples.name>
Fri, 9 Oct 2020 13:45:57 +0000 (14:45 +0100)
committerRoy Marples <roy@marples.name>
Fri, 9 Oct 2020 13:45:57 +0000 (14:45 +0100)
Otherwise we won't call inet_dispatch on a message meant for it.

src/privsep-bpf.c

index 465bb57e2435a42eaa6b056f0a23eadf0a407b26..ddd3cd824c25adeb7f54a2ddc8e31281d3000dd5 100644 (file)
@@ -253,6 +253,17 @@ ps_bpf_dispatch(struct dhcpcd_ctx *ctx,
        uint8_t *bpf;
        size_t bpf_len;
 
+       switch (psm->ps_cmd) {
+#ifdef ARP
+       case PS_BPF_ARP:
+#endif
+       case PS_BPF_BOOTP:
+               break;
+       default:
+               errno = ENOTSUP;
+               return -1;
+       }
+
        ifp = if_findindex(ctx->ifaces, psm->ps_id.psi_ifindex);
        /* interface may have departed .... */
        if (ifp == NULL)
@@ -270,9 +281,6 @@ ps_bpf_dispatch(struct dhcpcd_ctx *ctx,
        case PS_BPF_BOOTP:
                dhcp_packet(ifp, bpf, bpf_len, (unsigned int)psm->ps_flags);
                break;
-       default:
-               errno = ENOTSUP;
-               return -1;
        }
 
        return 1;