]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
bsd: ensure we also have space for the BPF header
authorVincent Bernat <vincent@bernat.im>
Thu, 15 May 2014 23:18:07 +0000 (01:18 +0200)
committerVincent Bernat <vincent@bernat.im>
Thu, 15 May 2014 23:32:42 +0000 (01:32 +0200)
src/daemon/interfaces-bpf.c
src/daemon/priv-bsd.c

index a03a11bc8e8ea05a1f2039dad9e3eaf3c1d06308..024e13c42b0f15a4dcb0a157b5de7109ddda9b7f 100644 (file)
@@ -38,14 +38,14 @@ ifbpf_phys_init(struct lldpd *cfg,
 
        /* Allocate receive buffer */
        hardware->h_data = buffer =
-           malloc(ETHER_MAX_LEN + sizeof(struct bpf_buffer));
+           malloc(ETHER_MAX_LEN + sizeof(struct bpf_hdr) + sizeof(struct bpf_buffer));
        if (buffer == NULL) {
                log_warn("interfaces",
                    "unable to allocate buffer space for BPF on %s",
                    hardware->h_ifname);
                goto end;
        }
-       buffer->len = ETHER_MAX_LEN;
+       buffer->len = ETHER_MAX_LEN + sizeof(struct bpf_hdr);
 
        /* Setup multicast */
        interfaces_setup_multicast(cfg, hardware->h_ifname, 0);
index 3a61b2d14199fb334eb78d4914c24b4d49b71e58..abcd10305ce1220debf5902fe1420074bdc45dd2 100644 (file)
@@ -54,7 +54,7 @@ asroot_iface_init_os(int ifindex, char *name, int *fd)
        }
 
        /* Set buffer size */
-       required = ETHER_MAX_LEN;
+       required = ETHER_MAX_LEN + sizeof(struct bpf_hdr);
        if (ioctl(*fd, BIOCSBLEN, (caddr_t)&required) < 0) {
                rc = errno;
                log_warn("privsep",