diff options
| author | Roy Marples <roy@marples.name> | 2008-11-04 10:04:25 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2008-11-04 10:04:25 +0000 |
| commit | 4c240a4a92ca40661353c9e27061cfbe4bbf1807 (patch) | |
| tree | 892c5a1f2d1e037e8e858ef9d12505a1cf2b2ff0 /dhcp.c | |
| parent | 459f34f308040bba6ddc6d3a2a90e228185de44c (diff) | |
| download | dhcpcd-4c240a4a92ca40661353c9e27061cfbe4bbf1807.tar.xz | |
Trim trailing NULLs from string options, #120.
Diffstat (limited to 'dhcp.c')
| -rw-r--r-- | dhcp.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -1008,13 +1008,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) { |
