diff options
author | phk <phk@FreeBSD.org> | 2004-04-04 07:28:58 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2004-04-04 07:28:58 +0000 |
commit | 206a45d61be5ca88e2c20bb0b08582a3b75d4430 (patch) | |
tree | 5d410f37d512c2840a71f48059688af091a25898 /sbin/ifconfig | |
parent | 354a4aac472244ab756318afe15ec52b9ee00b44 (diff) | |
download | FreeBSD-src-206a45d61be5ca88e2c20bb0b08582a3b75d4430.zip FreeBSD-src-206a45d61be5ca88e2c20bb0b08582a3b75d4430.tar.gz |
Fix an off-by-one error in the function used to input the ascii/hex strings.
Be a little bit more helpful in error messages.
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r-- | sbin/ifconfig/ifieee80211.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c index 6f83de0..1e83e80 100644 --- a/sbin/ifconfig/ifieee80211.c +++ b/sbin/ifconfig/ifieee80211.c @@ -546,17 +546,20 @@ get_string(const char *val, const char *sep, u_int8_t *buf, int *lenp) break; } if (hexstr) { - if (!isxdigit((u_char)val[0]) || - !isxdigit((u_char)val[1])) { + if (!isxdigit((u_char)val[0])) { warnx("bad hexadecimal digits"); return NULL; } + if (!isxdigit((u_char)val[1])) { + warnx("odd count hexadecimal digits"); + return NULL; + } } - if (p > buf + len) { + if (p >= buf + len) { if (hexstr) warnx("hexadecimal digits too long"); else - warnx("strings too long"); + warnx("string too long"); return NULL; } if (hexstr) { |