diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c index 5cef7abe40fb..ffd01f6cfd7c 100644 --- a/sbin/ifconfig/ifieee80211.c +++ b/sbin/ifconfig/ifieee80211.c @@ -1913,9 +1913,10 @@ get_string(const char *val, const char *sep, u_int8_t *buf, int *lenp) } len = p - buf; /* The string "-" is treated as the empty string. */ - if (!hexstr && len == 1 && buf[0] == '-') + if (!hexstr && len == 1 && buf[0] == '-') { len = 0; - if (len < *lenp) + memset(buf, 0, *lenp); + } else if (len < *lenp) memset(p, 0, *lenp - len); *lenp = len; return val;