]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP: Avoid mis-aligned BOOTP structure
authorRoy Marples <roy@marples.name>
Mon, 20 Apr 2020 21:16:24 +0000 (22:16 +0100)
committerRoy Marples <roy@marples.name>
Mon, 20 Apr 2020 21:16:24 +0000 (22:16 +0100)
This was caused by the recent change to pass back the frame header.

src/dhcp.c

index 958720339976690272e9fd4c3e8dc0a2c665ed19..8d13c9b684ffae6d821963b55d6a43e283f3d66c 100644 (file)
@@ -3453,12 +3453,16 @@ dhcp_readbpf(void *arg)
                        }
                        break;
                }
-               if (bytes < fl) {
-                       logerrx("%s: %s: short frame header",
-                           __func__, ifp->name);
-                       break;
+               if (fl != 0) {
+                       if (bytes < fl) {
+                               logerrx("%s: %s: short frame header",
+                                   __func__, ifp->name);
+                               break;
+                       }
+                       bytes -= fl;
+                       memmove(buf, buf + fl, (size_t)bytes);
                }
-               dhcp_packet(ifp, buf + fl, (size_t)(bytes - fl));
+               dhcp_packet(ifp, buf, (size_t)bytes);
                /* Check we still have a state after processing. */
                if ((state = D_STATE(ifp)) == NULL)
                        break;