From 206a45d61be5ca88e2c20bb0b08582a3b75d4430 Mon Sep 17 00:00:00 2001 From: phk Date: Sun, 4 Apr 2004 07:28:58 +0000 Subject: 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. --- sbin/ifconfig/ifieee80211.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sbin/ifconfig/ifieee80211.c') 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) { -- cgit v1.1