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

index a56d47f4f00c5ede384a3e8aa32b0ec95638cdef..efee50874a98c768ff693b89680032c14e63f97a 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_hdr) + sizeof(struct bpf_buffer));
+           malloc(ETHER_MAX_LEN + BPF_WORDALIGN(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 + sizeof(struct bpf_hdr);
+       buffer->len = ETHER_MAX_LEN + BPF_WORDALIGN(sizeof(struct bpf_hdr));
 
        /* Setup multicast */
        interfaces_setup_multicast(cfg, hardware->h_ifname, 0);
index abcd10305ce1220debf5902fe1420074bdc45dd2..0537f25c6f03283b819fc86e2a2c2a8a13616f38 100644 (file)
@@ -54,7 +54,7 @@ asroot_iface_init_os(int ifindex, char *name, int *fd)
        }
 
        /* Set buffer size */
-       required = ETHER_MAX_LEN + sizeof(struct bpf_hdr);
+       required = ETHER_MAX_LEN + BPF_WORDALIGN(sizeof(struct bpf_hdr));
        if (ioctl(*fd, BIOCSBLEN, (caddr_t)&required) < 0) {
                rc = errno;
                log_warn("privsep",