Fix a stack overflow in ifconfig(8).
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 8 Dec 2006 14:25:07 +0000 (14:25 +0000)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 8 Dec 2006 14:25:07 +0000 (14:25 +0000)
commitabd0386a74c56bd83342732bcf84575141544cc3
tree4b099b4225e78c47f57534ac78431e2e92013261
parentaca8cb3410e5e2b1d9b6be2ef7dd63c7ec9ce4c0
Fix a stack overflow in ifconfig(8).

The stack overflow happens, if "-" is passed as the argument to 'ssid' or
'wepkey' commands.  The offender is ifieee80211.c:get_string()'s "-" special
handling:
...
len = p - buf;
/* The string "-" is treated as the empty string. */
if (!hexstr && len == 1 && buf[0] == '-')
len = 0;
if (len < *lenp)
memset(p, 0, *lenp - len);
...

If the string is "-", the 'p' will be 1 byte beyound 'buf' and 'len' is set to
0.  'len' must be less than '*lenp' here, so memset() will be called.  But the
length, used to clear the buffer, is 1 byte larger the buffer pointed by 'p'
sbin/ifconfig/ifieee80211.c