From: Roy Marples Date: Mon, 20 Apr 2020 21:16:24 +0000 (+0100) Subject: DHCP: Avoid mis-aligned BOOTP structure X-Git-Tag: v8.1.9~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83fba2aeaeba9ace7f4aeff85c36322296236ffc;p=thirdparty%2Fdhcpcd.git DHCP: Avoid mis-aligned BOOTP structure This was caused by the recent change to pass back the frame header. --- diff --git a/src/dhcp.c b/src/dhcp.c index 95872033..8d13c9b6 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -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;