Skip to content

Commit b5eadb5

Browse files
committed
fix(esp_wifi): Fix stack corruption in wpa3 task
1 parent 534fce5 commit b5eadb5

File tree

1 file changed

+11
-19
lines changed
  • components/wpa_supplicant/esp_supplicant/src

1 file changed

+11
-19
lines changed

components/wpa_supplicant/esp_supplicant/src/esp_wpa3.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -412,38 +412,32 @@ SemaphoreHandle_t g_wpa3_hostap_auth_api_lock = NULL;
412412

413413
int wpa3_hostap_post_evt(uint32_t evt_id, uint32_t data)
414414
{
415-
wpa3_hostap_auth_event_t *evt = os_zalloc(sizeof(wpa3_hostap_auth_event_t));
416-
if (evt == NULL) {
417-
return ESP_FAIL;
418-
}
419-
evt->id = evt_id;
420-
evt->data = data;
415+
wpa3_hostap_auth_event_t evt;
416+
417+
evt.id = evt_id;
418+
evt.data = data;
421419

422420
if (g_wpa3_hostap_auth_api_lock) {
423421
WPA3_HOSTAP_AUTH_API_LOCK();
424422
if (g_wpa3_hostap_evt_queue == NULL) {
425423
WPA3_HOSTAP_AUTH_API_UNLOCK();
426-
os_free(evt);
427424
wpa_printf(MSG_DEBUG, "hostap evt queue NULL");
428425
return ESP_FAIL;
429426
}
430427
} else {
431-
os_free(evt);
432428
wpa_printf(MSG_DEBUG, "g_wpa3_hostap_auth_api_lock not found");
433429
return ESP_FAIL;
434430
}
435-
if (evt->id == SIG_WPA3_RX_CONFIRM || evt->id == SIG_TASK_DEL) {
431+
if (evt.id == SIG_WPA3_RX_CONFIRM || evt.id == SIG_TASK_DEL) {
436432
/* prioritising confirm for completing handshake for committed sta */
437433
if (os_queue_send_to_front(g_wpa3_hostap_evt_queue, &evt, 0) != pdPASS) {
438434
WPA3_HOSTAP_AUTH_API_UNLOCK();
439435
wpa_printf(MSG_DEBUG, "failed to add msg to queue front");
440-
os_free(evt);
441436
return ESP_FAIL;
442437
}
443438
} else {
444439
if (os_queue_send(g_wpa3_hostap_evt_queue, &evt, 0) != pdPASS) {
445440
WPA3_HOSTAP_AUTH_API_UNLOCK();
446-
os_free(evt);
447441
wpa_printf(MSG_DEBUG, "failed to send msg to queue");
448442
return ESP_FAIL;
449443
}
@@ -562,18 +556,18 @@ static void wpa3_process_rx_confirm(wpa3_hostap_auth_event_t *evt)
562556

563557
static void esp_wpa3_hostap_task(void *pvParameters)
564558
{
565-
wpa3_hostap_auth_event_t *evt;
559+
wpa3_hostap_auth_event_t evt;
566560
bool task_del = false;
567561

568562
while (1) {
569563
if (os_queue_recv(g_wpa3_hostap_evt_queue, &evt, portMAX_DELAY) == pdTRUE) {
570-
switch (evt->id) {
564+
switch (evt.id) {
571565
case SIG_WPA3_RX_COMMIT: {
572-
wpa3_process_rx_commit(evt);
566+
wpa3_process_rx_commit(&evt);
573567
break;
574568
}
575569
case SIG_WPA3_RX_CONFIRM: {
576-
wpa3_process_rx_confirm(evt);
570+
wpa3_process_rx_confirm(&evt);
577571
break;
578572
}
579573
case SIG_TASK_DEL:
@@ -582,7 +576,6 @@ static void esp_wpa3_hostap_task(void *pvParameters)
582576
default:
583577
break;
584578
}
585-
os_free(evt);
586579

587580
if (task_del) {
588581
break;
@@ -593,10 +586,9 @@ static void esp_wpa3_hostap_task(void *pvParameters)
593586
while (items_in_queue--) {
594587
/* Free events posted to queue */
595588
os_queue_recv(g_wpa3_hostap_evt_queue, &evt, portMAX_DELAY);
596-
if (evt->id == SIG_WPA3_RX_CONFIRM) {
597-
os_free((void *)evt->data);
589+
if (evt.id == SIG_WPA3_RX_CONFIRM) {
590+
os_free((void *)evt.data);
598591
}
599-
os_free(evt);
600592
}
601593
os_queue_delete(g_wpa3_hostap_evt_queue);
602594
g_wpa3_hostap_evt_queue = NULL;

0 commit comments

Comments
 (0)