From 0972edc076c07dc8ccca02fd379810bcdc53fea4 Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Sat, 9 Dec 2006 20:11:55 +0000 Subject: [PATCH] fix handling of ssid "-" etc; we're writing 1 byte past the end of the result buffer Noticed by: Sepherosa Zieha Reviewed by: cperciva MFC after: 2 weeks --- sbin/ifconfig/ifieee80211.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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;