* [PATCH] knownnetworks: sanitize known_network.freq on load
@ 2021-01-29 23:07 James Prestwood
0 siblings, 0 replies; 2+ messages in thread
From: James Prestwood @ 2021-01-29 23:07 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 962 bytes --]
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.
---
src/knownnetworks.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/knownnetworks.c b/src/knownnetworks.c
index 53cfc30f..32beae84 100644
--- a/src/knownnetworks.c
+++ b/src/knownnetworks.c
@@ -916,6 +916,11 @@ static int known_network_frequencies_load(void)
if (!info)
continue;
+ if (info->has_uuid) {
+ l_settings_remove_group(known_freqs, groups[i]);
+ continue;
+ }
+
freq_list = l_settings_get_string(known_freqs, groups[i],
"list");
if (!freq_list)
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH] knownnetworks: sanitize known_network.freq on load
@ 2021-01-29 21:35 James Prestwood
0 siblings, 0 replies; 2+ messages in thread
From: James Prestwood @ 2021-01-29 21:35 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 1683 bytes --]
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 any verification that the UUID matches
whatever provisioning file we have on disk. This leads to the
same network_info's known_frequencies being set/overridden
multiple times.
To fix this the UUID/group is verified after we lookup the
network_info. If it does not match the stale entry is removed
and synced to disk.
---
src/knownnetworks.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/knownnetworks.c b/src/knownnetworks.c
index 53cfc30f..9a6d8aad 100644
--- a/src/knownnetworks.c
+++ b/src/knownnetworks.c
@@ -889,6 +889,21 @@ static struct network_info *find_network_info_from_path(const char *path)
return search.info;
}
+static bool verify_network_uuid(struct network_info *info,
+ const char *uuid_check)
+{
+ char uuid_str[37];
+ const uint8_t *uuid = network_info_get_uuid(info);
+
+ if (!l_uuid_to_string(uuid, uuid_str, sizeof(uuid_str)))
+ return false;
+
+ if (!strcmp(uuid_str, uuid_check))
+ return true;
+
+ return false;
+}
+
static int known_network_frequencies_load(void)
{
char **groups;
@@ -916,6 +931,12 @@ static int known_network_frequencies_load(void)
if (!info)
continue;
+ if (!verify_network_uuid(info, groups[i])) {
+ l_settings_remove_group(known_freqs, groups[i]);
+ known_network_frequency_sync(info);
+ continue;
+ }
+
freq_list = l_settings_get_string(known_freqs, groups[i],
"list");
if (!freq_list)
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-29 23:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-29 23:07 [PATCH] knownnetworks: sanitize known_network.freq on load James Prestwood
-- strict thread matches above, loose matches on Subject: below --
2021-01-29 21:35 James Prestwood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox