Fix possible freed-memory use in BSS table updates
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 27 Sep 2013 12:47:09 +0000 (15:47 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 27 Sep 2013 12:56:06 +0000 (15:56 +0300)
commita3cbf82e6d2b494e4c5e87b4101af2f941482400
tree7e54cdc5e58a1ca9f9c05294ea909204b4974381
parentbbc6c729a58897e9265d53d53677b3ddeda4ff94
Fix possible freed-memory use in BSS table updates

If there are large number of BSSes in the scan results, BSS table update
could have added a BSS entry to the last_scan_res in a case where that
BSS entry got just deleted. This would happen only if there are more
than bss_max_count (by default 200) BSSes and if at least bss_max_count
of those BSSes are known (match a configured network). In such a case,
wpa_bss_add() could end up allocating a new BSS entry and return a
pointer to that entry even if it was the one that ended up getting freed
to keep the BSS table length within the limit. This could result in
freed memory being used and the process crashing (likely with segfault)
when trying to access information from that BSS entry.

Fix the issue by removing the oldest BSS entry before linking the new
entry to the table. This makes sure the newly added entry will never get
picked up as the one to be deleted immediately.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
wpa_supplicant/bss.c