summaryrefslogtreecommitdiffstats
path: root/dhcp.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-08-05 22:04:34 +0000
committerRoy Marples <roy@marples.name>2008-08-05 22:04:34 +0000
commita6d8a84a142a44764ccd292c8d468ab4d07c58cc (patch)
treea93b08c03d45d8398624e8510a6e541eae6ba828 /dhcp.c
parent6faa58fe5b8fee66179af85a928125728d6d3269 (diff)
downloaddhcpcd-a6d8a84a142a44764ccd292c8d468ab4d07c58cc.tar.xz
Respect hostname length.
Diffstat (limited to 'dhcp.c')
-rw-r--r--dhcp.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/dhcp.c b/dhcp.c
index 533b29d9..09bf4e6b 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -713,10 +713,8 @@ make_message(struct dhcp_message **message,
uint32_t ul;
uint16_t sz;
const struct dhcp_opt *opt;
-#ifndef MINIMAL
uint8_t *d;
- const char *c;
-#endif
+ const char *c, *e;
dhcp = xzalloc(sizeof (*dhcp));
m = (uint8_t *)dhcp;
@@ -854,8 +852,9 @@ make_message(struct dhcp_message **message,
*p++ = 0; /* from server for PTR RR */
*p++ = 0; /* from server for A RR if S=1 */
c = options->hostname + 1;
+ e = c + options->hostname[0];
d = p++;
- while (*c) {
+ while (c < e) {
if (*c == '.') {
*d = p - d - 1;
d = p++;
@@ -863,7 +862,7 @@ make_message(struct dhcp_message **message,
*p++ = (uint8_t) *c;
c++;
}
- *p ++ = 0;
+ *p++ = 0;
}
}