diff options
-rw-r--r-- | sbin/dhclient/bpf.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c index abda36e..911acb4 100644 --- a/sbin/dhclient/bpf.c +++ b/sbin/dhclient/bpf.c @@ -325,7 +325,9 @@ receive_packet(struct interface_info *interface, unsigned char *buf, * do is drop it. */ if (hdr.bh_caplen != hdr.bh_datalen) { - interface->rbuf_offset += hdr.bh_caplen; + interface->rbuf_offset = + BPF_WORDALIGN(interface->rbuf_offset + + hdr.bh_caplen); continue; } @@ -339,7 +341,9 @@ receive_packet(struct interface_info *interface, unsigned char *buf, * this packet. */ if (offset < 0) { - interface->rbuf_offset += hdr.bh_caplen; + interface->rbuf_offset = + BPF_WORDALIGN(interface->rbuf_offset + + hdr.bh_caplen); continue; } interface->rbuf_offset += offset; @@ -351,7 +355,9 @@ receive_packet(struct interface_info *interface, unsigned char *buf, /* If the IP or UDP checksum was bad, skip the packet... */ if (offset < 0) { - interface->rbuf_offset += hdr.bh_caplen; + interface->rbuf_offset = + BPF_WORDALIGN(interface->rbuf_offset + + hdr.bh_caplen); continue; } interface->rbuf_offset += offset; @@ -363,14 +369,18 @@ receive_packet(struct interface_info *interface, unsigned char *buf, * life, though). */ if (hdr.bh_caplen > len) { - interface->rbuf_offset += hdr.bh_caplen; + interface->rbuf_offset = + BPF_WORDALIGN(interface->rbuf_offset + + hdr.bh_caplen); continue; } /* Copy out the data in the packet... */ memcpy(buf, interface->rbuf + interface->rbuf_offset, hdr.bh_caplen); - interface->rbuf_offset += hdr.bh_caplen; + interface->rbuf_offset = + BPF_WORDALIGN(interface->rbuf_offset + + hdr.bh_caplen); return (hdr.bh_caplen); } while (!length); return (0); |