aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-11-01 11:45:03 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-11-01 11:48:21 +0100
commitca82b5354feca83374c78a7bdd43ef3aab9204e9 (patch)
treeadce85a79694bf367a8ccc4e74d44cda467d7919 /shell
parent151de441e7a19ce3afba0c59b083240a801222cf (diff)
downloadbusybox-w32-ca82b5354feca83374c78a7bdd43ef3aab9204e9.tar.gz
busybox-w32-ca82b5354feca83374c78a7bdd43ef3aab9204e9.tar.bz2
busybox-w32-ca82b5354feca83374c78a7bdd43ef3aab9204e9.zip
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.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 58ecf6d2c..19004aad8 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
8017{ 8017{
8018#if ENABLE_FEATURE_SH_STANDALONE 8018#if ENABLE_FEATURE_SH_STANDALONE
8019 if (applet_no >= 0) { 8019 if (applet_no >= 0) {
8020# if NUM_SCRIPTS > 0
8021 if (applet_no >= NUM_APPLETS)
8022 goto run_script;
8023# endif
8020 if (APPLET_IS_NOEXEC(applet_no)) { 8024 if (APPLET_IS_NOEXEC(applet_no)) {
8021 clearenv(); 8025 clearenv();
8022 while (*envp) 8026 while (*envp)
@@ -8039,7 +8043,11 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) const char *cmd, char **argv, c
8039#else 8043#else
8040 execve(cmd, argv, envp); 8044 execve(cmd, argv, envp);
8041#endif 8045#endif
8046
8042 if (cmd != bb_busybox_exec_path && errno == ENOEXEC) { 8047 if (cmd != bb_busybox_exec_path && errno == ENOEXEC) {
8048#if ENABLE_FEATURE_SH_STANDALONE && NUM_SCRIPTS > 0
8049 run_script:
8050#endif
8043 /* Run "cmd" as a shell script: 8051 /* Run "cmd" as a shell script:
8044 * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html 8052 * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
8045 * "If the execve() function fails with ENOEXEC, the shell 8053 * "If the execve() function fails with ENOEXEC, the shell