From: Roy Marples Date: Tue, 4 Nov 2008 10:04:40 +0000 (+0000) Subject: Trim trailing NULLs from string options, #120. X-Git-Tag: v4.0.5~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5734df38d847c0d6d38823dc93fe6a714d6bf430;p=thirdparty%2Fdhcpcd.git Trim trailing NULLs from string options, #120. --- diff --git a/dhcp.c b/dhcp.c index 0f61e187..e5371684 100644 --- a/dhcp.c +++ b/dhcp.c @@ -1009,13 +1009,21 @@ static ssize_t print_string(char *s, ssize_t len, int dl, const uint8_t *data) { uint8_t c; - const uint8_t *e; + const uint8_t *e, *p; ssize_t bytes = 0; ssize_t r; e = data + dl; while (data < e) { c = *data++; + if (c == '\0') { + /* If rest is all NULL, skip it. */ + for (p = data; p < e; p++) + if (*p != '\0') + break; + if (p == e) + break; + } if (!isascii(c) || !isprint(c)) { if (s) { if (len < 5) {