aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-19 00:29:22 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-19 00:29:22 +0000
commit249fabf1a3ce08273d6bef2adbcd0910cc4dcb4a (patch)
treeec8143ae80ee51c6b1df792e3d7ed66014fdd5ab
parent15b213ef5a0834eb06a0183ab839ac883d829d5a (diff)
downloadbusybox-w32-249fabf1a3ce08273d6bef2adbcd0910cc4dcb4a.tar.gz
busybox-w32-249fabf1a3ce08273d6bef2adbcd0910cc4dcb4a.tar.bz2
busybox-w32-249fabf1a3ce08273d6bef2adbcd0910cc4dcb4a.zip
Add option to disable command execution from vi & awk
-rw-r--r--editors/Config.in9
-rw-r--r--editors/awk.c3
-rw-r--r--editors/vi.c8
3 files changed, 16 insertions, 4 deletions
diff --git a/editors/Config.in b/editors/Config.in
index 4ba009019..fd840ae9a 100644
--- a/editors/Config.in
+++ b/editors/Config.in
@@ -127,5 +127,12 @@ config FEATURE_VI_OPTIMIZE_CURSOR
127 This will make the cursor movement faster, but requires more memory 127 This will make the cursor movement faster, but requires more memory
128 and it makes the applet a tiny bit larger. 128 and it makes the applet a tiny bit larger.
129 129
130endmenu 130config FEATURE_ALLOW_EXEC
131 bool "Allow vi and awk to execute shell commands"
132 default y
133 depends on VI || AWK
134 help
135 Enables vi and awk features which allows user to execute
136 shell commands (using system() C call).
131 137
138endmenu
diff --git a/editors/awk.c b/editors/awk.c
index 9386f4ec0..147c621ab 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -2378,7 +2378,8 @@ re_cont:
2378 2378
2379 case F_sy: 2379 case F_sy:
2380 fflush(NULL); 2380 fflush(NULL);
2381 R.d = (L.s && *L.s) ? (system(L.s) >> 8) : 0; 2381 R.d = (ENABLE_FEATURE_ALLOW_EXEC && L.s && *L.s)
2382 ? (system(L.s) >> 8) : 0;
2382 break; 2383 break;
2383 2384
2384 case F_ff: 2385 case F_ff:
diff --git a/editors/vi.c b/editors/vi.c
index eef895c53..0bb2b23ef 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -660,7 +660,9 @@ static void colon(Byte * buf)
660 dot = find_line(b); // what line is #b 660 dot = find_line(b); // what line is #b
661 dot_skip_over_ws(); 661 dot_skip_over_ws();
662 } 662 }
663 } else if (strncmp((char *) cmd, "!", 1) == 0) { // run a cmd 663 }
664#if ENABLE_FEATURE_ALLOW_EXEC
665 else if (strncmp((char *) cmd, "!", 1) == 0) { // run a cmd
664 // :!ls run the <cmd> 666 // :!ls run the <cmd>
665 (void) alarm(0); // wait for input- no alarms 667 (void) alarm(0); // wait for input- no alarms
666 place_cursor(rows - 1, 0, FALSE); // go to Status line 668 place_cursor(rows - 1, 0, FALSE); // go to Status line
@@ -670,7 +672,9 @@ static void colon(Byte * buf)
670 rawmode(); 672 rawmode();
671 Hit_Return(); // let user see results 673 Hit_Return(); // let user see results
672 (void) alarm(3); // done waiting for input 674 (void) alarm(3); // done waiting for input
673 } else if (strncmp((char *) cmd, "=", i) == 0) { // where is the address 675 }
676#endif
677 else if (strncmp((char *) cmd, "=", i) == 0) { // where is the address
674 if (b < 0) { // no addr given- use defaults 678 if (b < 0) { // no addr given- use defaults
675 b = e = count_lines(text, dot); 679 b = e = count_lines(text, dot);
676 } 680 }