summaryrefslogtreecommitdiffstats
path: root/dhcp.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-11-04 10:04:25 +0000
committerRoy Marples <roy@marples.name>2008-11-04 10:04:25 +0000
commit4c240a4a92ca40661353c9e27061cfbe4bbf1807 (patch)
tree892c5a1f2d1e037e8e858ef9d12505a1cf2b2ff0 /dhcp.c
parent459f34f308040bba6ddc6d3a2a90e228185de44c (diff)
downloaddhcpcd-4c240a4a92ca40661353c9e27061cfbe4bbf1807.tar.xz
Trim trailing NULLs from string options, #120.
Diffstat (limited to 'dhcp.c')
-rw-r--r--dhcp.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/dhcp.c b/dhcp.c
index c8631e39..9f84a3ff 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -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) {