2 Copyright (C) 2006 OpenWrt.org
4 diff -urN busybox.old/shell/ash.c busybox.dev/shell/ash.c
5 --- busybox.old/shell/ash.c 2005-11-12 22:39:19.853826250 +0100
6 +++ busybox.dev/shell/ash.c 2005-11-12 22:39:42.771258500 +0100
9 #define NUMBUILTINS (sizeof (builtincmd) / sizeof (struct builtincmd) )
11 +static const char *safe_applets[] = {
12 + "[", "test", "echo", "cat",
13 + "ln", "cp", "touch", "mkdir", "rm",
14 + "cut", "hexdump", "awk", "sort",
15 + "find", "xargs", "ls", "dd",
21 @@ -2050,6 +2057,19 @@
22 static void exitshell(void) __attribute__((__noreturn__));
23 static int decode_signal(const char *, int);
26 +static int is_safe_applet(char *name)
28 + int n = sizeof(safe_applets) / sizeof(char *);
30 + for (i = 0; i < n; i++)
31 + if (strcmp(safe_applets[i], name) == 0)
39 * This routine is called when an error or an interrupt occurs in an
40 * interactive shell and control is returned to the main command loop.
44 if (strchr(argv[0], '/') != NULL
45 + || is_safe_applet(argv[0])
46 #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
47 || find_applet_by_name(argv[0])
49 @@ -3721,6 +3742,18 @@
50 tryexec(char *cmd, char **argv, char **envp)
53 + struct BB_applet *a;
57 + if(strchr(cmd, '/') == NULL && is_safe_applet(cmd) && (a = find_applet_by_name(cmd)) != NULL) {
59 + while (*c != NULL) {
62 + bb_applet_name = cmd;
63 + exit(a->main(argc, argv));
65 #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
68 @@ -3919,6 +3952,12 @@
72 + if (is_safe_applet(name)) {
73 + entry->cmdtype = CMDNORMAL;
74 + entry->u.index = -1;
78 updatetbl = (path == pathval());