diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2018-06-06 14:07:34 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2018-06-08 17:27:46 -0300 |
commit | 283d98512272a12cb84e7798c23edbdf1adb287d (patch) | |
tree | 3691f644eb1109e70b48e97ac64314c9fdcedb7f /include/unistd.h | |
parent | 67c0579669ba1fc265d770252fab31babf887329 (diff) | |
download | glibc-283d98512272a12cb84e7798c23edbdf1adb287d.tar.gz glibc-283d98512272a12cb84e7798c23edbdf1adb287d.tar.xz glibc-283d98512272a12cb84e7798c23edbdf1adb287d.zip |
posix: Fix posix_spawnp to not execute invalid binaries in non compat mode (BZ#23264)
Current posix_spawnp implementation wrongly tries to execute invalid binaries (for instance script without shebang) as a shell script in non compat mode. It was a regression introduced by 9ff72da471a509a8c19791efe469f47fa6977410 when __spawni started to use __execvpe instead of __execve (glibc __execvpe try to execute ENOEXEC as shell script regardless). This patch fixes it by using an internal symbol (__execvpex) with the faulty semantic (since compat mode is handled by spawni.c itself). It was reported by Daniel Drake on libc-help [1]. Checked on x86_64-linux-gnu and i686-linux-gnu. [BZ #23264] * include/unistd.h (__execvpex): New prototype. * posix/Makefile (tests): Add tst-spawn4. (tests-internal): Add tst-spawn4-compat. * posix/execvpe.c (__execvpe_common, __execvpex): New functions. * posix/tst-spawn4-compat.c: New file. * posix/tst-spawn4.c: Likewise. * sysdeps/unix/sysv/linux/spawni.c (__spawni): Do not interpret invalid binaries as shell scripts. * sysdeps/posix/spawni.c (__spawni): Likewise. [1] https://sourceware.org/ml/libc-help/2018-06/msg00012.html
Diffstat (limited to 'include/unistd.h')
-rw-r--r-- | include/unistd.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/unistd.h b/include/unistd.h index 0f91b8babc..a171b00326 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -77,6 +77,8 @@ extern char *__getcwd (char *__buf, size_t __size) attribute_hidden; extern int __rmdir (const char *__path) attribute_hidden; extern int __execvpe (const char *file, char *const argv[], char *const envp[]) attribute_hidden; +extern int __execvpex (const char *file, char *const argv[], + char *const envp[]) attribute_hidden; /* Get the canonical absolute name of the named directory, and put it in SIZE bytes of BUF. Returns NULL if the directory couldn't be determined or |