]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Respect hostname length.
authorRoy Marples <roy@marples.name>
Tue, 5 Aug 2008 22:04:34 +0000 (22:04 +0000)
committerRoy Marples <roy@marples.name>
Tue, 5 Aug 2008 22:04:34 +0000 (22:04 +0000)
dhcp.c

diff --git a/dhcp.c b/dhcp.c
index 533b29d922600dcc80ef97af1afe174b763532cc..09bf4e6b98230087776b42ca882bd6cd7e22b28c 100644 (file)
--- 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;
                        }
                }