mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
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
9ff72da471
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
This commit is contained in:
@ -404,6 +404,8 @@ __spawni (pid_t * pid, const char *file,
|
||||
const posix_spawnattr_t * attrp, char *const argv[],
|
||||
char *const envp[], int xflags)
|
||||
{
|
||||
/* It uses __execvpex to avoid run ENOEXEC in non compatibility mode (it
|
||||
will be handled by maybe_script_execute). */
|
||||
return __spawnix (pid, file, acts, attrp, argv, envp, xflags,
|
||||
xflags & SPAWN_XFLAGS_USE_PATH ? __execvpe : __execve);
|
||||
xflags & SPAWN_XFLAGS_USE_PATH ? __execvpex :__execve);
|
||||
}
|
||||
|
Reference in New Issue
Block a user