diff mbox series

[COMMITTED] posix: Fix segfault in maybe_script_execute

Message ID 20181203202349.2300-1-adhemerval.zanella@linaro.org
State New
Headers show
Series [COMMITTED] posix: Fix segfault in maybe_script_execute | expand

Commit Message

Adhemerval Zanella Dec. 3, 2018, 8:23 p.m. UTC
This patch is essentially 28669f86f6 adjusted for the generic
implementation.

Checked on x86_64-linux-gnu with Linux spawni.c removed.  The only
failure is posix/tst-spawn3, which is expected.

	[BZ #23913]
	* sysdeps/posix/spawni.c (maybe_script_execute):
	Increment size of new_argv by one.
---
 ChangeLog              | 6 ++++++
 sysdeps/posix/spawni.c | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

-- 
2.17.1

Comments

Adhemerval Zanella Dec. 3, 2018, 8:25 p.m. UTC | #1
On 03/12/2018 18:23, Adhemerval Zanella wrote:
> This patch is essentially 28669f86f6 adjusted for the generic

> implementation.

> 

> Checked on x86_64-linux-gnu with Linux spawni.c removed.  The only

> failure is posix/tst-spawn3, which is expected.

> 

> 	[BZ #23913]

> 	* sysdeps/posix/spawni.c (maybe_script_execute):

> 	Increment size of new_argv by one.

> ---

>  ChangeLog              | 6 ++++++

>  sysdeps/posix/spawni.c | 2 +-

>  2 files changed, 7 insertions(+), 1 deletion(-)

> 

> diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c

> index c42fbd590e..c02171cc61 100644

> --- a/sysdeps/posix/spawni.c

> +++ b/sysdeps/posix/spawni.c

> @@ -68,7 +68,7 @@ maybe_script_execute (struct posix_spawn_args *args)

>        ptrdiff_t argc = args->argc;

>  

>        /* Construct an argument list for the shell.  */

> -      char *new_argv[argc + 1];

> +      char *new_argv[argc + 2];

>        new_argv[0] = (char *) _PATH_BSHELL;

>        new_argv[1] = (char *) args->file;

>        if (argc > 1)

> 


As a side note, I wonder if it is worth to keep this reference implementation
(it is currently not used in any supported platform).
diff mbox series

Patch

diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c
index c42fbd590e..c02171cc61 100644
--- a/sysdeps/posix/spawni.c
+++ b/sysdeps/posix/spawni.c
@@ -68,7 +68,7 @@  maybe_script_execute (struct posix_spawn_args *args)
       ptrdiff_t argc = args->argc;
 
       /* Construct an argument list for the shell.  */
-      char *new_argv[argc + 1];
+      char *new_argv[argc + 2];
       new_argv[0] = (char *) _PATH_BSHELL;
       new_argv[1] = (char *) args->file;
       if (argc > 1)