diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2005-07-15 10:40:28 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2005-07-15 10:40:28 +0000 |
commit | 43632e3d730268bafa55235975e11603f4f5e3f6 (patch) | |
tree | 96b1c3a0f3e7a984f9e082d2a3e35feb86a58ffc | |
parent | 5d86db48f100ec074c778d872451ec371aa655fc (diff) |
let pretty_print_option() handle trailing nul bytes correctly (i. e. don't
let a trailing nul byte force hex printing)
FreeBSD PR 83468 by Sean Winn <sean@gothic.net.au>, via jmc@
-rw-r--r-- | sbin/dhclient/options.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c index 42fa492d75a..18e77264e8b 100644 --- a/sbin/dhclient/options.c +++ b/sbin/dhclient/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.22 2005/07/13 23:33:04 deraadt Exp $ */ +/* $OpenBSD: options.c,v 1.23 2005/07/15 10:40:27 henning Exp $ */ /* DHCP options parsing and reassembly. */ @@ -279,7 +279,11 @@ pretty_print_option(unsigned int code, unsigned char *data, int len, if (!isascii(data[k]) || !isprint(data[k])) break; - if (k == len) { + /* If we found no bogus characters, or the bogus + character we found is a trailing NUL, it's + okay to print this option as text. */ + + if (k == len || (k + 1 == len && data [k] == 0)) { fmtbuf[i] = 't'; numhunk = -2; } else { |