[PATCH] gsupplicant: fix ASAN issue
Ram Subramanian <[email protected]>
| Newsgroups | dev.linux.lists.connman |
|---|---|
| Message-ID | <[email protected]> |
The problem is `bss` and `bss->path` can be used after being freed, in this line: g_hash_table_replace(bss_mapping, bss->path, interface); This is because the following call: g_hash_table_replace(network->bss_table, ...) could call remove_bss(), which will free both `bss->path` and `bss`. So this commit switches the order of these statements. Additionally, change `g_hash_table_replace` to `g_hash_table_insert`. We already checked that `network->group` doesn't exist in `interface->network_table` at this point. Co-Authored-By: Chris Johnson <[email protected]> --- gsupplicant/supplicant.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index 1b92ec44..f3be9e7b 100644 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -1708,7 +1708,7 @@ static int add_or_replace_bss_to_network(struct g_supplicant_bss *bss) network->config_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); - g_hash_table_replace(interface->network_table, + g_hash_table_insert(interface->network_table, network->group, network); callback_network_added(network); @@ -1735,9 +1735,8 @@ done: } g_hash_table_replace(interface->bss_mapping, bss->path, network); - g_hash_table_replace(network->bss_table, bss->path, bss); - g_hash_table_replace(bss_mapping, bss->path, interface); + g_hash_table_replace(network->bss_table, bss->path, bss); return 0; } -- 2.47.0 -- *Confidentiality Note:* We care about protecting our proprietary information, confidential material, and trade secrets. This message may contain some or all of those things. Cruise will suffer material harm if anyone other than the intended recipient disseminates or takes any action based on this message. If you have received this message (including any attachments) in error, please delete it immediately and notify the sender promptly.