hostapd: use strdup on string passed to hostapd_add_iface
authorFelix Fietkau <nbd@nbd.name>
Fri, 14 Jun 2024 12:17:57 +0000 (14:17 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Mon, 8 Jul 2024 19:13:25 +0000 (21:13 +0200)
The data is modified within hostapd_add_iface

Signed-off-by: Felix Fietkau <nbd@nbd.name>
(cherry picked from commit 032d3fcf7a861b140435b6507b2b0b66361c92f8)
Link: https://github.com/openwrt/openwrt/pull/15898
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
package/network/services/hostapd/src/src/ap/ucode.c

index af97091be55e82e0e0fe509fcdb045a2e2629574..80c01b4b9be78e4dfa5366a5e769915f13e29a93 100644 (file)
@@ -86,12 +86,16 @@ static uc_value_t *
 uc_hostapd_add_iface(uc_vm_t *vm, size_t nargs)
 {
        uc_value_t *iface = uc_fn_arg(0);
+       char *data;
        int ret;
 
        if (ucv_type(iface) != UC_STRING)
                return ucv_int64_new(-1);
 
-       ret = hostapd_add_iface(interfaces, ucv_string_get(iface));
+       data = strdup(ucv_string_get(iface));
+       ret = hostapd_add_iface(interfaces, data);
+       free(data);
+
        hostapd_ucode_update_interfaces();
 
        return ucv_int64_new(ret);