From 986effcb7a97a38f2af744e54462b13c09ea7e95 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Fri, 16 May 2014 01:18:07 +0200 Subject: [PATCH] bsd: ensure we also have space for the BPF header --- src/daemon/interfaces-bpf.c | 4 ++-- src/daemon/priv-bsd.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/daemon/interfaces-bpf.c b/src/daemon/interfaces-bpf.c index a03a11bc..024e13c4 100644 --- a/src/daemon/interfaces-bpf.c +++ b/src/daemon/interfaces-bpf.c @@ -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); diff --git a/src/daemon/priv-bsd.c b/src/daemon/priv-bsd.c index 3a61b2d1..abcd1030 100644 --- a/src/daemon/priv-bsd.c +++ b/src/daemon/priv-bsd.c @@ -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", -- 2.47.2