kmod/backport-modprobe-fix-the-NULL-termination-of-new_argv.patch

36 lines
1.1 KiB
Diff

From 757b3599236c0fee9e2bb0770eb6b7c84a271276 Mon Sep 17 00:00:00 2001
From: Masahiro Yamada <masahiroy@kernel.org>
Date: Thu, 10 Feb 2022 11:14:22 +0900
Subject: [PATCH] modprobe: fix the NULL-termination of new_argv
Conflict:NA
Reference:https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/commit?id=757b3599236c0fee9e2bb0770eb6b7c84a271276
The number of new arguments is (i + argc - 1) as it is set to *p_argc
one line below.
The correct location of NULL termination is new_argv[i + argc - 1].
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
tools/modprobe.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/modprobe.c b/tools/modprobe.c
index eed951f..48b1c8c 100644
--- a/tools/modprobe.c
+++ b/tools/modprobe.c
@@ -744,7 +744,7 @@ static char **prepend_options_from_env(int *p_argc, char **orig_argv)
}
memcpy(new_argv + i, orig_argv + 1, sizeof(char *) * (argc - 1));
- new_argv[i + argc] = NULL;
+ new_argv[i + argc - 1] = NULL;
*p_argc = i + argc - 1;
return new_argv;
--
2.33.0