]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix segfault in maybe_script_execute.
authorStefan Liebler <stli@linux.ibm.com>
Thu, 6 Sep 2018 12:27:03 +0000 (14:27 +0200)
committerStefan Liebler <stli@linux.ibm.com>
Mon, 10 Sep 2018 12:27:40 +0000 (14:27 +0200)
If glibc is built with gcc 8 and -march=z900,
the testcase posix/tst-spawn4-compat crashes with a segfault.

In function maybe_script_execute, the new_argv array is dynamically
initialized on stack with (argc + 1) elements.
The function wants to add _PATH_BSHELL as the first argument
and writes out of bounds of new_argv.
There is an off-by-one because maybe_script_execute fails to count
the terminating NULL when sizing new_argv.

ChangeLog:

* sysdeps/unix/sysv/linux/spawni.c (maybe_script_execute):
Increment size of new_argv by one.

(cherry picked from commit 28669f86f6780a18daca264f32d66b1428c9c6f1)

ChangeLog
sysdeps/unix/sysv/linux/spawni.c

index 2b771ca994565563d5bd478df12ed10ab3cb22bc..6848c7d550778b2df017801fa6c0fb5aee74c89f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-09-06  Stefan Liebler  <stli@linux.ibm.com>
+
+       * sysdeps/unix/sysv/linux/spawni.c (maybe_script_execute):
+       Increment size of new_argv by one.
+
 2018-08-27 Martin Kuchta  <martin.kuchta@netapp.com>
           Torvald Riegel  <triegel@redhat.com>
 
index 7d23df84d2545a15ead37c207347f15f4398b6d0..2d7502adaaa4e74b254200777a9145835025ae4f 100644 (file)
@@ -101,7 +101,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)