Explorar el Código

hostapd: clear ucode interface/bss resource pointers

Avoids potential use-after-free bugs

Signed-off-by: Felix Fietkau <[email protected]>
Felix Fietkau hace 2 años
padre
commit
ea1787b7bc
Se han modificado 1 ficheros con 8 adiciones y 2 borrados
  1. 8 2
      package/network/services/hostapd/src/src/utils/ucode.c

+ 8 - 2
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;
 }