summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-01-29 13:56:23 +0000
committerRoy Marples <roy@marples.name>2009-01-29 13:56:23 +0000
commit4ac6a5d2f9b7955e9316cd85a9717132354f4423 (patch)
tree495162a0b3386148f1926ab653b5ea8725cd0307
parent141c80922499959330d53f41f5f5a54e39bdb40c (diff)
downloaddhcpcd-4ac6a5d2f9b7955e9316cd85a9717132354f4423.tar.xz
Just terminate the DHCP message if not terminated. DHO_PAD could be valid data.
-rw-r--r--dhcpcd.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/dhcpcd.c b/dhcpcd.c
index d5383971..0dd9b289 100644
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -609,10 +609,8 @@ handle_dhcp_packet(void *arg)
}
/* We should ensure that the packet is terminated correctly
* if we have space for the terminator */
- if ((size_t)bytes < sizeof(struct dhcp_message)) {
- p = (uint8_t *)dhcp + bytes - 1;
- while (p > dhcp->options && *p == DHO_PAD)
- p--;
+ if ((size_t)bytes != sizeof(*dhcp)) {
+ p = (uint8_t *)dhcp + (bytes - 1);
if (*p != DHO_END)
*++p = DHO_END;
}