From 8c35c8e6a00d8d4fc5e78987e7aa61f93a110e89 Mon Sep 17 00:00:00 2001 From: David Bauer Date: Tue, 21 Sep 2021 18:51:57 +0200 Subject: [PATCH] local-node: don't read pointer after clear The name pointer provided by ubus get's cleared after the first call to ubus_register_subscriber in usteer_get_node. The leads to an incorrect ifindex returned by if_nametoindex due to the 0 characters long string. Work around this issue by reusing the interface name already stored in the local node struct. Fixes querying the wrong interface with netlink, resulting in incorrect SSIDs used for the nodes. Signed-off-by: David Bauer --- local_node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local_node.c b/local_node.c index 985b37b..8064bd7 100644 --- a/local_node.c +++ b/local_node.c @@ -447,7 +447,7 @@ usteer_register_node(struct ubus_context *ctx, const char *name, uint32_t id) ln = usteer_get_node(ctx, name); ln->obj_id = id; ln->iface = usteer_node_name(&ln->node) + offset; - ln->ifindex = if_nametoindex(iface); + ln->ifindex = if_nametoindex(ln->iface); blob_buf_init(&b, 0); blobmsg_add_u32(&b, "notify_response", 1);