From 60bde9c63e01f1932e0ce782946989f942739dfb Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 5 Feb 2020 14:54:49 +0000 Subject: [PATCH] ARP: Only copy out frame header if we have it. Frameless does exist. --- src/arp.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) 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)) -- 2.47.2