If /tmp/test.sh is a script that tries to run a second script which
happens to be non-executable this:

   command . /tmp/test.sh

causes a seg fault.

This is because clearredir is called in the error path to clear the
stack of redirections.  The normal path then calls popredir, but popredir
fails when the stack is empty.

Reported-by: Bastian Bittorf <[email protected]>
Signed-off-by: Ron Yorston <[email protected]>
---
 shell/ash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/shell/ash.c b/shell/ash.c
index db6fb8f..ebe8a4e 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -5412,7 +5412,7 @@ popredir(int drop, int restore)
        struct redirtab *rp;
        int i;
 
-       if (--g_nullredirs >= 0)
+       if (g_nullredirs == 0 || --g_nullredirs >= 0)
                return;
        INT_OFF;
        rp = redirlist;
-- 
2.4.3

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to