really fix webif password access patch for busybox
[openwrt.git] / package / busybox / patches / 190-ash_performance.patch
1
2 Copyright (C) 2006 OpenWrt.org
3
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
7 @@ -1414,6 +1414,13 @@
8
9 #define NUMBUILTINS (sizeof (builtincmd) / sizeof (struct builtincmd) )
10
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",
16 + "chown", "chmod"
17 +};
18
19
20 struct cmdentry {
21 @@ -2050,6 +2057,19 @@
22 static void exitshell(void) __attribute__((__noreturn__));
23 static int decode_signal(const char *, int);
24
25 +
26 +static int is_safe_applet(char *name)
27 +{
28 + int n = sizeof(safe_applets) / sizeof(char *);
29 + int i;
30 + for (i = 0; i < n; i++)
31 + if (strcmp(safe_applets[i], name) == 0)
32 + return 1;
33 +
34 + return 0;
35 +}
36 +
37 +
38 /*
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.
41 @@ -3680,6 +3700,7 @@
42 clearredir(1);
43 envp = environment();
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])
48 #endif
49 @@ -3721,6 +3742,18 @@
50 tryexec(char *cmd, char **argv, char **envp)
51 {
52 int repeated = 0;
53 + struct BB_applet *a;
54 + int argc = 0;
55 + char **c;
56 +
57 + if(strchr(cmd, '/') == NULL && is_safe_applet(cmd) && (a = find_applet_by_name(cmd)) != NULL) {
58 + c = argv;
59 + while (*c != NULL) {
60 + c++; argc++;
61 + }
62 + bb_applet_name = cmd;
63 + exit(a->main(argc, argv));
64 + }
65 #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
66 int flg_bb = 0;
67 char *name = cmd;
68 @@ -3919,6 +3952,12 @@
69 }
70 #endif
71
72 + if (is_safe_applet(name)) {
73 + entry->cmdtype = CMDNORMAL;
74 + entry->u.index = -1;
75 + return;
76 + }
77 +
78 updatetbl = (path == pathval());
79 if (!updatetbl) {
80 act |= DO_ALTPATH;
This page took 0.042995 seconds and 5 git commands to generate.