From ea1787b7bcf537ffddad9aae3aab8381942c24cc Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 12 Sep 2023 13:32:40 +0200 Subject: [PATCH] hostapd: clear ucode interface/bss resource pointers Avoids potential use-after-free bugs Signed-off-by: Felix Fietkau --- package/network/services/hostapd/src/src/utils/ucode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/package/network/services/hostapd/src/src/utils/ucode.c b/package/network/services/hostapd/src/src/utils/ucode.c index 896ef46e1f..2beeb9a7ff 100644 --- a/package/network/services/hostapd/src/src/utils/ucode.c +++ b/package/network/services/hostapd/src/src/utils/ucode.c @@ -298,9 +298,15 @@ uc_value_t *wpa_ucode_registry_get(uc_value_t *reg, int idx) uc_value_t *wpa_ucode_registry_remove(uc_value_t *reg, int idx) { uc_value_t *val = wpa_ucode_registry_get(reg, idx); + void **dataptr; - if (val) - ucv_array_set(reg, idx - 1, NULL); + if (!val) + return NULL; + + ucv_array_set(reg, idx - 1, NULL); + dataptr = ucv_resource_dataptr(val, NULL); + if (dataptr) + *dataptr = NULL; return val; } -- 2.30.2