]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Don't trust bootp->sname to be NULL terminated.
authorRoy Marples <roy@marples.name>
Tue, 29 Nov 2016 21:20:59 +0000 (21:20 +0000)
committerRoy Marples <roy@marples.name>
Tue, 29 Nov 2016 21:20:59 +0000 (21:20 +0000)
dhcp.c

diff --git a/dhcp.c b/dhcp.c
index c78d23ed6ddb0302cae01f347154724e29eb5ea6..d19a7c08f131746bf907cea985832c18aef0bf67 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -2678,7 +2678,7 @@ log_dhcp(int lvl, const char *msg,
     const struct in_addr *from, int ad)
 {
        const char *tfrom;
-       char *a,  sname[sizeof(bootp->sname) * 4];
+       char *a, sname[sizeof(bootp->sname) * 4];
        struct in_addr addr;
        int r;
        uint8_t overl;
@@ -2717,8 +2717,8 @@ log_dhcp(int lvl, const char *msg,
            DHO_OPTSOVERLOADED) == -1)
                overl = 0;
        if (bootp->sname[0] && r == 0 && !(overl & 2)) {
-               print_string(sname, sizeof(sname), OT_STRING,
-                   bootp->sname, strlen((const char *)bootp->sname));
+               print_string(sname, sizeof(sname), OT_STRING | OT_DOMAIN,
+                   bootp->sname, sizeof(bootp->sname));
                if (a == NULL)
                        logger(ifp->ctx, lvl, "%s: %s %s %s `%s'",
                            ifp->name, msg, tfrom, inet_ntoa(addr), sname);