From: Felix Fietkau Date: Tue, 12 Sep 2023 11:32:40 +0000 (+0200) Subject: hostapd: clear ucode interface/bss resource pointers X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=ea1787b7bcf537ffddad9aae3aab8381942c24cc;p=openwrt%2Fstaging%2Fansuel.git hostapd: clear ucode interface/bss resource pointers Avoids potential use-after-free bugs Signed-off-by: Felix Fietkau --- 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; }