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
This commit is contained in:
Sam Leffler 2006-12-09 20:11:55 +00:00
parent 3e6f3ff080
commit 0972edc076
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=165045

View File

@ -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;