Message ID | 20220210021423.3388827-1-masahiroy@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] modprobe: fix the NULL-termination of new_argv | expand |
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 >
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
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;
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(-)