From: Roy Marples Date: Tue, 29 Nov 2016 21:20:59 +0000 (+0000) Subject: Don't trust bootp->sname to be NULL terminated. X-Git-Tag: v7.0.0-beta1~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a4dab67cb68b19a04d454f30782123415b9934a;p=thirdparty%2Fdhcpcd.git Don't trust bootp->sname to be NULL terminated. --- diff --git a/dhcp.c b/dhcp.c index c78d23ed..d19a7c08 100644 --- 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);