aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-05-09 22:16:08 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-05-09 22:16:08 +0000
commit2b54aaa9bf38eedc3c35604e19ae5415f6e9f2df (patch)
tree6aeaadbb6c72bfe66f4c620e2c556d84c9ced318
parent389f9d52d5520dea157fab474caacf3d8b1bde73 (diff)
downloadbusybox-w32-2b54aaa9bf38eedc3c35604e19ae5415f6e9f2df.tar.gz
busybox-w32-2b54aaa9bf38eedc3c35604e19ae5415f6e9f2df.tar.bz2
busybox-w32-2b54aaa9bf38eedc3c35604e19ae5415f6e9f2df.zip
msh: fix obscure case with backticks and closed fd 1
-rw-r--r--shell/msh.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/shell/msh.c b/shell/msh.c
index 4feede6fa..ac49af14c 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -2546,7 +2546,7 @@ static int execute(struct op *t, int *pin, int *pout, int act)
2546 interactive = 0; 2546 interactive = 0;
2547 if (pin == NULL) { 2547 if (pin == NULL) {
2548 close(0); 2548 close(0);
2549 open(bb_dev_null, O_RDONLY); 2549 xopen(bb_dev_null, O_RDONLY);
2550 } 2550 }
2551 _exit(execute(t->left, pin, pout, FEXEC)); 2551 _exit(execute(t->left, pin, pout, FEXEC));
2552 } 2552 }
@@ -2823,12 +2823,12 @@ static int forkexec(struct op *t, int *pin, int *pout, int act, char **wp)
2823#endif 2823#endif
2824 2824
2825 if (pin != NULL) { 2825 if (pin != NULL) {
2826 dup2(pin[0], 0); 2826 xmove_fd(pin[0], 0);
2827 closepipe(pin); 2827 if (pin[1] != 0) close(pin[1]);
2828 } 2828 }
2829 if (pout != NULL) { 2829 if (pout != NULL) {
2830 dup2(pout[1], 1); 2830 xmove_fd(pout[1], 1);
2831 closepipe(pout); 2831 if (pout[1] != 1) close(pout[0]);
2832 } 2832 }
2833 2833
2834 iopp = t->ioact; 2834 iopp = t->ioact;
@@ -4166,8 +4166,13 @@ static int grave(int quoted)
4166 if (ourtrap[j] && signal(j, SIG_IGN) != SIG_IGN) 4166 if (ourtrap[j] && signal(j, SIG_IGN) != SIG_IGN)
4167 signal(j, SIG_DFL); 4167 signal(j, SIG_DFL);
4168 4168
4169 dup2(pf[1], 1); 4169 /* Testcase where below checks are needed:
4170 closepipe(pf); 4170 * close stdout & run this script:
4171 * files=`ls`
4172 * echo "$files" >zz
4173 */
4174 xmove_fd(pf[1], 1);
4175 if (pf[0] != 1) close(pf[0]);
4171 4176
4172 argument_list[0] = (char *) DEFAULT_SHELL; 4177 argument_list[0] = (char *) DEFAULT_SHELL;
4173 argument_list[1] = (char *) "-c"; 4178 argument_list[1] = (char *) "-c";