Blame SOURCES/kmod-0006-depmod-module_is_higher_priority-fix-modname-length-.patch

ca9082
From dd73c8a2f5e8da3c38f6e16c63f249071d440378 Mon Sep 17 00:00:00 2001
ca9082
From: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
ca9082
Date: Thu, 7 Dec 2017 20:59:54 +0200
ca9082
Subject: [PATCH 2/2] depmod: module_is_higher_priority: fix modname length
ca9082
 calculation
ca9082
ca9082
depmod_module_is_higher_priority checks module's path if it is under
ca9082
module root directory and if so uses relative to the root path to
ca9082
lookup the module in override and search lists.
ca9082
ca9082
Originally only relative path was used in the function, so the
ca9082
variables with full path and and path length were changed:
ca9082
ca9082
       newpath += cfg->dirnamelen + 1;
ca9082
       newlen -= cfg->dirnamelen + 1;
ca9082
       oldpath += cfg->dirnamelen + 1;
ca9082
       oldlen -= cfg->dirnamelen + 1;
ca9082
ca9082
Commit 7da6884e7357ac05772e90f6d7e63b1948103fc4 (depmod: implement
ca9082
external directories support) changed the logic since it need the
ca9082
full path to the module for comparations as well.
ca9082
ca9082
Unfortunately, it introduce a mistake in calculation of the relative
ca9082
paths replacing '-=' with assignment to a new variable -- the
ca9082
'cfg->dirnamelen + 1' value must be substracted all together. It
ca9082
breaks, for example, overrides lookup.
ca9082
ca9082
Fix the calculation by putting braces around the value in the
ca9082
subsctuction expression.
ca9082
ca9082
Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
ca9082
---
ca9082
 tools/depmod.c | 4 ++--
ca9082
 1 file changed, 2 insertions(+), 2 deletions(-)
ca9082
ca9082
diff --git a/tools/depmod.c b/tools/depmod.c
ca9082
index 7ff3e9ed191e..921dc5cc93eb 100644
ca9082
--- a/tools/depmod.c
ca9082
+++ b/tools/depmod.c
ca9082
@@ -1118,11 +1118,11 @@ static int depmod_module_is_higher_priority(const struct depmod *depmod, const s
ca9082
 
ca9082
 	if (strncmp(newpath, cfg->dirname, cfg->dirnamelen) == 0) {
ca9082
 		relnewpath = newpath + cfg->dirnamelen + 1;
ca9082
-		relnewlen = newlen - cfg->dirnamelen + 1;
ca9082
+		relnewlen = newlen - (cfg->dirnamelen + 1);
ca9082
 	}
ca9082
 	if (strncmp(oldpath, cfg->dirname, cfg->dirnamelen) == 0) {
ca9082
 		reloldpath = oldpath + cfg->dirnamelen + 1;
ca9082
-		reloldlen = oldlen - cfg->dirnamelen + 1;
ca9082
+		reloldlen = oldlen - (cfg->dirnamelen + 1);
ca9082
 	}
ca9082
 
ca9082
 	for (ov = cfg->overrides; ov != NULL; ov = ov->next) {
ca9082
-- 
ca9082
2.15.1
ca9082