summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-04-20 22:16:24 +0100
committerRoy Marples <roy@marples.name>2020-04-20 22:16:24 +0100
commit83fba2aeaeba9ace7f4aeff85c36322296236ffc (patch)
tree49544c102457c635d707692c819a76edade65e43
parenta52bd7cdf755f4d2d6f3c0b6c2083d7ecc3f25ca (diff)
downloaddhcpcd-83fba2aeaeba9ace7f4aeff85c36322296236ffc.tar.xz
DHCP: Avoid mis-aligned BOOTP structure
This was caused by the recent change to pass back the frame header.
-rw-r--r--src/dhcp.c14
1 files changed, 9 insertions, 5 deletions
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;