3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 13:02:44 +01:00

client: Fix network name completion after restart of iwd

Previously, on service disappeared event the list of the known
proxy objects was cleared, but pointers to the default entity
per command family wasn’t reset. Reset default entities for
the command families to remove the dead pointers to the deleted
proxy objects.

==1325== Invalid read of size 8
==1325==    at 0x4055D4: proxy_interface_is_same (dbus-proxy.c:439)
==1325==    by 0x407C28: match_by_partial_name (network.c:220)
==1325==    by 0x40547C: proxy_interface_find_all (dbus-proxy.c:424)
==1325==    by 0x405592: proxy_property_str_completion (dbus-proxy.c:153)
==1325==    by 0x407DA9: network_name_completion (network.c:241)
==1325==    by 0x4E596D5: rl_completion_matches (in /usr/lib64/libreadline.so.7.0)
This commit is contained in:
Tim Kourt 2019-07-17 16:36:53 -07:00 committed by Denis Kenzior
parent fd1a267313
commit f1dd6b1084
4 changed files with 25 additions and 0 deletions

View File

@ -555,6 +555,21 @@ int command_get_exit_status(void)
return exit_status;
}
void command_reset_default_entities(void)
{
const struct l_queue_entry *entry;
for (entry = l_queue_get_entries(command_families); entry;
entry = entry->next) {
struct command_family *family = entry->data;
if (!family->reset_default_entity)
continue;
family->reset_default_entity();
}
}
void command_family_register(const struct command_family *family)
{
l_queue_push_tail(command_families, (void *) family);

View File

@ -49,6 +49,7 @@ struct command_family {
command_completion_func_t family_arg_completion;
command_completion_func_t entity_arg_completion;
void (*set_default_entity)(const char *entity);
void (*reset_default_entity)(void);
};
bool command_line_find_token(const char *token, uint8_t num_to_inspect);
@ -62,6 +63,7 @@ void command_noninteractive_trigger(void);
bool command_is_interactive_mode(void);
int command_get_exit_status(void);
void command_set_exit_status(int status);
void command_reset_default_entities(void);
void command_family_register(const struct command_family *family);
void command_family_unregister(const struct command_family *family);

View File

@ -734,6 +734,8 @@ static void service_disappeared_callback(struct l_dbus *dbus,
l_queue_clear(proxy_interfaces, proxy_interface_destroy);
command_reset_default_entities();
display_disable_cmd_prompt();
}

View File

@ -306,6 +306,11 @@ static void device_set_default(const char *device_name)
l_queue_destroy(match, NULL);
}
static void device_reset_default(void)
{
default_device = NULL;
}
const struct proxy_interface *device_get_default(void)
{
struct l_queue *match;
@ -483,6 +488,7 @@ static struct command_family device_command_family = {
.family_arg_completion = family_arg_completion,
.entity_arg_completion = entity_arg_completion,
.set_default_entity = device_set_default,
.reset_default_entity = device_reset_default,
};
static int device_command_family_init(void)