All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] modprobe: fix the NULL-termination of new_argv
@ 2022-02-10  2:14 Masahiro Yamada
  2022-02-10  2:14 ` [PATCH 2/2] modprobe: remove unneeded variable str_start Masahiro Yamada
  2022-04-03 16:57 ` [PATCH 1/2] modprobe: fix the NULL-termination of new_argv Masahiro Yamada
  0 siblings, 2 replies; 4+ messages in thread
From: Masahiro Yamada @ 2022-02-10  2:14 UTC (permalink / raw)
  To: linux-modules; +Cc: Masahiro Yamada

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>
---

 tools/modprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/modprobe.c b/tools/modprobe.c
index 9387537..b6b2947 100644
--- a/tools/modprobe.c
+++ b/tools/modprobe.c
@@ -743,7 +743,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.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] modprobe: remove unneeded variable str_start
  2022-02-10  2:14 [PATCH 1/2] modprobe: fix the NULL-termination of new_argv Masahiro Yamada
@ 2022-02-10  2:14 ` Masahiro Yamada
  2022-04-03 16:57 ` [PATCH 1/2] modprobe: fix the NULL-termination of new_argv Masahiro Yamada
  1 sibling, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2022-02-10  2:14 UTC (permalink / raw)
  To: linux-modules; +Cc: Masahiro Yamada

The variable 'str_start' is not useful here.

Replace it with 'str'.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 tools/modprobe.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/modprobe.c b/tools/modprobe.c
index b6b2947..324fcfd 100644
--- a/tools/modprobe.c
+++ b/tools/modprobe.c
@@ -683,7 +683,7 @@ static int options_from_array(char **args, int nargs, char **output)
 static char **prepend_options_from_env(int *p_argc, char **orig_argv)
 {
 	const char *p, *env = getenv("MODPROBE_OPTIONS");
-	char **new_argv, *str_start, *str_end, *str, *s, *quote;
+	char **new_argv, *str_end, *str, *s, *quote;
 	int i, argc = *p_argc;
 	size_t envlen, space_count = 0;
 
@@ -701,10 +701,10 @@ static char **prepend_options_from_env(int *p_argc, char **orig_argv)
 		return NULL;
 
 	new_argv[0] = orig_argv[0];
-	str_start = str = (char *) (new_argv + argc + space_count + 3);
+	str = (char *) (new_argv + argc + space_count + 3);
 	memcpy(str, env, envlen + 1);
 
-	str_end = str_start + envlen;
+	str_end = str + envlen;
 
 	quote = NULL;
 	for (i = 1, s = str; *s != '\0'; s++) {
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] modprobe: fix the NULL-termination of new_argv
  2022-02-10  2:14 [PATCH 1/2] modprobe: fix the NULL-termination of new_argv Masahiro Yamada
  2022-02-10  2:14 ` [PATCH 2/2] modprobe: remove unneeded variable str_start Masahiro Yamada
@ 2022-04-03 16:57 ` Masahiro Yamada
  2022-04-04 15:17   ` Lucas De Marchi
  1 sibling, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2022-04-03 16:57 UTC (permalink / raw)
  To: linux-modules, Lucas De Marchi

Hi Lucas,

Ping?


On Thu, Feb 10, 2022 at 11:14 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> 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>
> ---
>
>  tools/modprobe.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/modprobe.c b/tools/modprobe.c
> index 9387537..b6b2947 100644
> --- a/tools/modprobe.c
> +++ b/tools/modprobe.c
> @@ -743,7 +743,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.32.0
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] modprobe: fix the NULL-termination of new_argv
  2022-04-03 16:57 ` [PATCH 1/2] modprobe: fix the NULL-termination of new_argv Masahiro Yamada
@ 2022-04-04 15:17   ` Lucas De Marchi
  0 siblings, 0 replies; 4+ messages in thread
From: Lucas De Marchi @ 2022-04-04 15:17 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: linux-modules

On Mon, Apr 04, 2022 at 01:57:41AM +0900, Masahiro Yamada wrote:
>Hi Lucas,
>
>Ping?

sorry for the delay. These 2 patches look good to me.

Applied. Thanks

Lucas De Marchi

>
>
>On Thu, Feb 10, 2022 at 11:14 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>>
>> 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>
>> ---
>>
>>  tools/modprobe.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/modprobe.c b/tools/modprobe.c
>> index 9387537..b6b2947 100644
>> --- a/tools/modprobe.c
>> +++ b/tools/modprobe.c
>> @@ -743,7 +743,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.32.0
>>
>
>
>-- 
>Best Regards
>Masahiro Yamada

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-04 15:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10  2:14 [PATCH 1/2] modprobe: fix the NULL-termination of new_argv Masahiro Yamada
2022-02-10  2:14 ` [PATCH 2/2] modprobe: remove unneeded variable str_start Masahiro Yamada
2022-04-03 16:57 ` [PATCH 1/2] modprobe: fix the NULL-termination of new_argv Masahiro Yamada
2022-04-04 15:17   ` Lucas De Marchi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.