From: Roy Marples Date: Wed, 5 Feb 2020 14:54:49 +0000 (+0000) Subject: ARP: Only copy out frame header if we have it. X-Git-Tag: v8.1.7~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60bde9c63e01f1932e0ce782946989f942739dfb;p=thirdparty%2Fdhcpcd.git ARP: Only copy out frame header if we have it. Frameless does exist. --- diff --git a/src/arp.c b/src/arp.c index 6e3d634a..15925a8f 100644 --- a/src/arp.c +++ b/src/arp.c @@ -228,16 +228,18 @@ arp_packet(struct interface *ifp, uint8_t *data, size_t len) /* Copy the frame header source and destination out */ memset(&arm, 0, sizeof(arm)); - hw_s = bpf_frame_header_src(ifp, data, &falen); - if (hw_s != NULL && falen <= sizeof(arm.fsha)) - memcpy(arm.fsha, hw_s, falen); - hw_t = bpf_frame_header_dst(ifp, data, &falen); - if (hw_t != NULL && falen <= sizeof(arm.ftha)) - memcpy(arm.ftha, hw_t, falen); - - /* Skip past the frame header */ - data += fl; - len -= fl; + if (fl != 0) { + hw_s = bpf_frame_header_src(ifp, data, &falen); + if (hw_s != NULL && falen <= sizeof(arm.fsha)) + memcpy(arm.fsha, hw_s, falen); + hw_t = bpf_frame_header_dst(ifp, data, &falen); + if (hw_t != NULL && falen <= sizeof(arm.ftha)) + memcpy(arm.ftha, hw_t, falen); + + /* Skip past the frame header */ + data += fl; + len -= fl; + } /* We must have a full ARP header */ if (len < sizeof(ar))