Fixed WEXT scan result parser to not crash on invalid IEs (zero len buffer)
authorJouni Malinen <jouni.malinen@atheros.com>
Wed, 27 Aug 2008 06:52:16 +0000 (09:52 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 27 Aug 2008 06:52:16 +0000 (09:52 +0300)
commitfd630bc183fb79d0a14b5f3a346544f3d277bd05
treeff8560fd85aa8f00a5124f00ebef4ef973e01661
parent00ad53ef6816a417fc7d3756c3652c5c0d605af9
Fixed WEXT scan result parser to not crash on invalid IEs (zero len buffer)

If IWEVGENIE or custom event wpa_ie/rsn_ie is received in scan with empty
buffer, the previous version ended up calling realloc(NULL, 0) which seems
to return a non-NULL value in some cases. When this return value is passed
again into realloc with realloc(ptr, 0), the returned value could be NULL.
If the ptr is then freed (os_free(data.ie) in SIOCGIWAP handling), glibc
may crash due to invalid pointer being freed (or double-freed?). The
non-NULL realloc(NULL, 0) return value from glibc looks a bit odd behavior,
but anyway, better avoid this case completely and just skip the IE events
that have an empty buffer.

This issue should not show up with drivers that produce proper scan results
since the IEs will always include the two-octet header. However, it seems
to be possible to see this when using 64-bit kernel and 32-bit userspace
with incorrect compat-ioctl processing.
src/drivers/driver_nl80211.c
src/drivers/driver_wext.c