aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Liebler <stli@linux.ibm.com>2018-09-06 14:27:03 +0200
committerStefan Liebler <stli@linux.ibm.com>2018-09-10 14:31:19 +0200
commit682f24d0f3995689f407dee842002099d3604586 (patch)
tree33ccd7a420458fec6469f9534573ad8237fc6703
parent17d5d67f4f0350bdcfb5bf1a31cef2e14dabf7de (diff)
downloadtermbaud-release/2.24/master.tar.gz
termbaud-release/2.24/master.tar.xz
termbaud-release/2.24/master.zip
Fix segfault in maybe_script_execute.release/2.24/master
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)
-rw-r--r--ChangeLog5
-rw-r--r--sysdeps/unix/sysv/linux/spawni.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 33f57580734..3305107bca9 100644
--- 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-01-19 H.J. Lu <hongjiu.lu@intel.com>
[BZ #22715]
diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index b5f20a710bc..abafd2070f9 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -100,7 +100,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)