From f979124dc9d49ee00c1f085e45fbabc1a008e9a9 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 11 Aug 2015 10:50:17 +0200 Subject: [PATCH] settings: add other check to ensure no duplicates in load_plugins() We already avoid loading duplicate plugins by checking find_plugin(). That iterates the plugins @list and checks for duplicate names. Additionally, also reject duplicates based on the @plugins list. Also, move the check for "keyfile" before, so that all explicit checks for (statically) known names are early and together. --- src/settings/nm-settings.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index 54d378ec6a..211c1b1e70 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -726,10 +726,6 @@ load_plugins (NMSettings *self, const char **plugins, GError **error) if (has_no_ibft && !strcmp (pname, "ibft")) continue; - obj = find_plugin (list, pname); - if (obj) - continue; - /* keyfile plugin is built-in now */ if (strcmp (pname, "keyfile") == 0) { if (!keyfile_added) { @@ -739,6 +735,17 @@ load_plugins (NMSettings *self, const char **plugins, GError **error) continue; } + if (_nm_utils_strv_find_first ((char **) plugins, + iter - plugins, + pname) >= 0) { + /* the plugin is already mentioned in the list previously. + * Don't load a duplicate. */ + continue; + } + + if (find_plugin (list, pname)) + continue; + load_plugin: { GModule *plugin;