mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-01 15:49:49 +01:00
knownnetworks: sanitize known_network.freq on load
An invalid known_network.freq file containing several UUID groups which have the same 'name' key results in memory leaks in IWD. This is because the file is loaded and the group's are iterated without detecting duplicates. This leads to the same network_info's known_frequencies being set/overridden multiple times. To fix this we just check if the network_info already has a UUID set. If so remove the stale entry. There may be other old, invalid, or stale entries from previous versions of IWD, or a user misconfiguring the file. These will now also be removed during load.
This commit is contained in:
parent
7b2ce98abd
commit
756158dfc9
@ -910,29 +910,38 @@ static int known_network_frequencies_load(void)
|
|||||||
const char *path = l_settings_get_value(known_freqs, groups[i],
|
const char *path = l_settings_get_value(known_freqs, groups[i],
|
||||||
"name");
|
"name");
|
||||||
if (!path)
|
if (!path)
|
||||||
continue;
|
goto invalid_entry;
|
||||||
|
|
||||||
info = find_network_info_from_path(path);
|
info = find_network_info_from_path(path);
|
||||||
if (!info)
|
if (!info)
|
||||||
continue;
|
goto invalid_entry;
|
||||||
|
|
||||||
|
if (info->has_uuid)
|
||||||
|
goto invalid_entry;
|
||||||
|
|
||||||
freq_list = l_settings_get_string(known_freqs, groups[i],
|
freq_list = l_settings_get_string(known_freqs, groups[i],
|
||||||
"list");
|
"list");
|
||||||
if (!freq_list)
|
if (!freq_list)
|
||||||
continue;
|
goto invalid_entry;
|
||||||
|
|
||||||
known_frequencies = known_frequencies_from_string(freq_list);
|
known_frequencies = known_frequencies_from_string(freq_list);
|
||||||
if (!known_frequencies)
|
l_free(freq_list);
|
||||||
goto next;
|
|
||||||
|
|
||||||
if (!l_uuid_from_string(groups[i], uuid))
|
if (!known_frequencies)
|
||||||
goto next;
|
goto invalid_entry;
|
||||||
|
|
||||||
|
if (!l_uuid_from_string(groups[i], uuid)) {
|
||||||
|
l_queue_destroy(known_frequencies, l_free);
|
||||||
|
goto invalid_entry;
|
||||||
|
}
|
||||||
|
|
||||||
network_info_set_uuid(info, uuid);
|
network_info_set_uuid(info, uuid);
|
||||||
info->known_frequencies = known_frequencies;
|
info->known_frequencies = known_frequencies;
|
||||||
|
|
||||||
next:
|
continue;
|
||||||
l_free(freq_list);
|
|
||||||
|
invalid_entry:
|
||||||
|
l_settings_remove_group(known_freqs, groups[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
l_strv_free(groups);
|
l_strv_free(groups);
|
||||||
|
Loading…
Reference in New Issue
Block a user