Merge branch 'bugfix/fixing_memory_leak_wps_scan_v4.2' into 'release/v4.2'

(wpa_supplicant) : Fixed a memory leak issue created when parsing scan results

See merge request espressif/esp-idf!20989
This commit is contained in:
Jiang Jiang Jian
2022-11-22 10:34:13 +08:00
2 changed files with 12 additions and 0 deletions

View File

@@ -598,6 +598,7 @@ wps_parse_scan_result(struct wps_scan_ie *scan)
for (count = 0; count < WPS_MAX_DIS_AP_NUM; count++) {
if (os_memcmp(sm->dis_ap_list[count].bssid, scan->bssid, ETH_ALEN) == 0) {
wpa_printf(MSG_INFO, "discard ap bssid "MACSTR, MAC2STR(scan->bssid));
wpabuf_free(buf);
return false;
}
}
@@ -606,6 +607,9 @@ wps_parse_scan_result(struct wps_scan_ie *scan)
if (ap_found || sm->wps_pin_war) {
wpabuf_free(buf);
if (scan->ssid[1] > SSID_MAX_LEN) {
return false;
}
esp_wifi_enable_sta_privacy_internal();
os_memset(sm->config.ssid, 0, sizeof(sm->config.ssid));
strncpy((char *)sm->config.ssid, (char *)&scan->ssid[2], (int)scan->ssid[1]);
@@ -1683,6 +1687,9 @@ _err:
sm->dev = NULL;
}
if (sm->wps_ctx) {
if (sm->wps_ctx->dh_privkey) {
wpabuf_free(sm->wps_ctx->dh_privkey);
}
os_free(sm->wps_ctx);
sm->wps_ctx = NULL;
}
@@ -1737,6 +1744,9 @@ wifi_station_wps_deinit(void)
sm->dev = NULL;
}
if (sm->wps_ctx) {
if (sm->wps_ctx->dh_privkey) {
wpabuf_free(sm->wps_ctx->dh_privkey);
}
os_free(sm->wps_ctx);
sm->wps_ctx = NULL;
}

View File

@@ -14,6 +14,8 @@
#include "os.h"
#include "esp_bit_defs.h"
#define SSID_MAX_LEN 32
/* Define platform specific variable type macros */
#if defined(ESP_PLATFORM)
#include <stdint.h>