From d96c7ef573c68c2ebb755a6505ed0fd7d670aaf6 Mon Sep 17 00:00:00 2001 From: avatar Date: Mon, 20 Jun 2005 02:33:02 +0000 Subject: Appending "..." to a SSID which contains unprintable characters only when necessary. Submitted by: sam Approved by: re (scottl) --- sbin/ifconfig/ifieee80211.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sbin') diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c index 8f85741..b85753f 100644 --- a/sbin/ifconfig/ifieee80211.c +++ b/sbin/ifconfig/ifieee80211.c @@ -712,15 +712,16 @@ copy_essid(char buf[], size_t bufsize, const u_int8_t *essid, size_t essid_len) bufsize -= 2; p = essid; for (i = 0; i < maxlen && bufsize >= 2; i++) { - sprintf(&buf[2+2*i], "%02x", *p++); + sprintf(&buf[2+2*i], "%02x", p[i]); bufsize -= 2; } - maxlen = 2+2*i; + if (i != essid_len) + memcpy(&buf[2+2*i-3], "...", 3); } else { /* printable, truncate as needed */ memcpy(buf, essid, maxlen); + if (maxlen != essid_len) + memcpy(&buf[maxlen-3], "...", 3); } - if (maxlen != essid_len) - memcpy(buf+maxlen-3, "...", 3); return maxlen; } -- cgit v1.1