]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
ARP: Only copy out frame header if we have it.
authorRoy Marples <roy@marples.name>
Wed, 5 Feb 2020 14:54:49 +0000 (14:54 +0000)
committerRoy Marples <roy@marples.name>
Wed, 5 Feb 2020 14:55:38 +0000 (14:55 +0000)
Frameless does exist.

src/arp.c

index 8c6acea90c4770efce3de54df6cb92f1339356f4..cd9ac4b5a523d16053828d1be2543ce06722f329 100644 (file)
--- a/src/arp.c
+++ b/src/arp.c
@@ -234,16 +234,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))