summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-02-05 14:54:49 +0000
committerRoy Marples <roy@marples.name>2020-02-05 14:54:49 +0000
commit60bde9c63e01f1932e0ce782946989f942739dfb (patch)
treec453e9b731655a4360714b10f6f2656e62fb9245
parent690685a2972cf7a90f585954433ce9f0753cd581 (diff)
downloaddhcpcd-60bde9c63e01f1932e0ce782946989f942739dfb.tar.xz
ARP: Only copy out frame header if we have it.
Frameless does exist.
-rw-r--r--src/arp.c22
1 files 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))