summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnssi Hannula <anssi@mageia.org>2014-03-19 01:26:00 +0200
committerLucas De Marchi <lucas.demarchi@intel.com>2014-03-19 09:18:39 -0300
commit49b33c1f215d5d58838845cbbaefc007bd0f9ac7 (patch)
treee4ad2555d78a8c3b9e164dbf470f228a58569a04
parentaa0abec721707da6cad794a1bf6da9ecdcefbe88 (diff)
downloadkmod-49b33c1f215d5d58838845cbbaefc007bd0f9ac7.tar.gz
kmod-49b33c1f215d5d58838845cbbaefc007bd0f9ac7.tar.bz2
kmod-49b33c1f215d5d58838845cbbaefc007bd0f9ac7.zip
depmod: do not allow partial matches with "search" directive
Currently e.g. "search foo foobar built-in" will cause unpredictable results if baz.ko is in both foo/ and foobar/, since "foo" in search may match both of those directories and the preferred module therefore depends on processing order. Fix the code to ensure that the match is performed on full pathname components only.
-rw-r--r--tools/depmod.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/depmod.c b/tools/depmod.c
index 6b5d21c..37e6afd 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -1153,10 +1153,10 @@ static int depmod_module_is_higher_priority(const struct depmod *depmod, const s
DBG("search %s\n", se->builtin ? "built-in" : se->path);
if (se->builtin)
bprio = i;
- else if (newlen >= se->len &&
+ else if (newlen > se->len && newpath[se->len] == '/' &&
memcmp(se->path, newpath, se->len) == 0)
newprio = i;
- else if (oldlen >= se->len &&
+ else if (oldlen > se->len && oldpath[se->len] == '/' &&
memcmp(se->path, oldpath, se->len) == 0)
oldprio = i;
}