aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2023-08-10 14:01:27 +0200
committerFelix Fietkau <nbd@nbd.name>2023-08-10 19:09:42 +0200
commit6cb8bb1675ec91bbd2c3b53b6a36d531330570d7 (patch)
treea168eadf88512770b10fa11bb5a553c8a3a60520
parent9feed15a0fe7381c2edc0eab1f899975f5991088 (diff)
hostapd: clone prototypes of ucode bss/interface objects
Fixes an issue where lookup would return different objects than the ones intended Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--package/network/services/hostapd/src/src/utils/ucode.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/package/network/services/hostapd/src/src/utils/ucode.c b/package/network/services/hostapd/src/src/utils/ucode.c
index fabf58a5e8..a92913aedc 100644
--- a/package/network/services/hostapd/src/src/utils/ucode.c
+++ b/package/network/services/hostapd/src/src/utils/ucode.c
@@ -179,6 +179,20 @@ uc_value_t *wpa_ucode_global_init(const char *name, uc_resource_type_t *global_t
return global;
}
+static uc_value_t *wpa_ucode_prototype_clone(uc_value_t *uval)
+{
+ uc_value_t *proto, *proto_new;
+
+ proto = ucv_prototype_get(uval);
+ proto_new = ucv_object_new(&vm);
+
+ ucv_object_foreach(proto, key, val)
+ ucv_object_add(proto_new, key, ucv_get(val));
+ ucv_prototype_set(uval, ucv_get(proto));
+
+ return proto;
+}
+
void wpa_ucode_registry_add(uc_value_t *reg, uc_value_t *val, int *idx)
{
uc_value_t *data;
@@ -190,7 +204,7 @@ void wpa_ucode_registry_add(uc_value_t *reg, uc_value_t *val, int *idx)
ucv_array_set(reg, i, ucv_get(val));
data = ucv_object_new(&vm);
- ucv_object_add(ucv_prototype_get(val), "data", ucv_get(data));
+ ucv_object_add(wpa_ucode_prototype_clone(val), "data", ucv_get(data));
*idx = i + 1;
}