diff options
author | Ron Yorston | 2018-11-01 11:45:03 +0100 |
---|---|---|
committer | Denys Vlasenko | 2018-11-01 11:48:21 +0100 |
commit | ca82b5354feca83374c78a7bdd43ef3aab9204e9 (patch) | |
tree | adce85a79694bf367a8ccc4e74d44cda467d7919 /shell | |
parent | 151de441e7a19ce3afba0c59b083240a801222cf (diff) | |
download | busybox-ca82b5354feca83374c78a7bdd43ef3aab9204e9.zip busybox-ca82b5354feca83374c78a7bdd43ef3aab9204e9.tar.gz |
ash: in tryexec(), ensure we don't try to run embedded scripts as applets
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c index 58ecf6d..19004aa 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -8017,6 +8017,10 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, c { #if ENABLE_FEATURE_SH_STANDALONE if (applet_no >= 0) { +# if NUM_SCRIPTS > 0 + if (applet_no >= NUM_APPLETS) + goto run_script; +# endif if (APPLET_IS_NOEXEC(applet_no)) { clearenv(); while (*envp) @@ -8039,7 +8043,11 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, c #else execve(cmd, argv, envp); #endif + if (cmd != bb_busybox_exec_path && errno == ENOEXEC) { +#if ENABLE_FEATURE_SH_STANDALONE && NUM_SCRIPTS > 0 + run_script: +#endif /* Run "cmd" as a shell script: * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html * "If the execve() function fails with ENOEXEC, the shell |