[BusyBox] bug#1293: busybox 0.60.5 ash builtin sh infinite loop

Dan Kegel dkegel at ixiacom.com
Fri Dec 20 16:46:03 UTC 2002


Package: busybox
Version: 0.60.5
Severity: normal

With following lines set in Config.h,
#define BB_ASH
#define BB_FEATURE_SH_IS_ASH
#define BB_FEATURE_SH_STANDALONE_SHELL

Given any script foo.sh, the command
     sh foo.sh
now hangs in an infinite loop in ash.c::findvar() before
actually executing foo.sh, while
     /bin/sh foo.sh
works.  This bug was not present in busybox 0.60.2.

The problem seems to start during a call to ash.c::initvar().
I added a call to showvarscmd() at the top of initvar(),
and at the bottom of the body of the first loop's if, i.e.

static void initvar()
{
     const struct varinit *ip;
     struct var *vp;
     struct var **vpp;

     printf("------initvar start:\n");
     showvars(nullstr, VUNSET, VUNSET);
     printf("------initvar start done\n");
     for (ip = varinit; (vp = ip->var) != NULL; ip++) {
         if ((vp->flags & VEXPORT) == 0) {
             printf("Exporting %s\n", ip->text);
             vpp = hashvar(ip->text);
             vp->next = *vpp;
             *vpp = vp;
             vp->text = xstrdup(ip->text);
             vp->flags = ip->flags;
             vp->func = ip->func;
             printf("------initvar after export:\n");
             showvars(nullstr, VUNSET, VUNSET);
             printf("------initvar after export done\n");
         }
     }

Built that and ran 'busybox sh', and inside that, did 'sh foo.sh'.

Sure enough, it showed an infinite loop in the list.
Here's the output from one run (trimmed to show only the last
call to initvars):

------initvar start:
HISTFILESIZE='6500'
USER='dank'
MAIL='/var/mail/dank'
SSH_AGENT_PID='8207'
SHLVL='3'
HOME='/home/dank'
OLDPWD='/home/dank/wk/ixos/dap'
HUSHLOGIN='FALSE'
PS1='$ '
OPTIND='1'
PS2='> '
COLORTERM=
LOGNAME='dank'
_='wsx86/busybox'
TERM='xterm'
ICAROOT='/opt/citrix'
HISTCONTROL='ignoredups'
PPID='8331'
PATH='/usr/java/j2sdk1.4.1_01/bin:/home/dank/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/bin/X11:/usr/local/bin:/usr/local/Acrobat4/bin'
DISPLAY=':0'
HISTSIZE='6500'
LANG='C'
XAUTHORITY='/home/dank/.Xauthority'
SSH_AUTH_SOCK='/tmp/ssh-XX0engWr/agent.8179'
P4CLIENT='dank-dank'
SHELL='/bin/bash'
HZ='100'
IFS='
'
CVSROOT=':pserver:anoncvs at sources.redhat.com:/cvs/mauve'
PWD='/home/dank/wk/ixos/dap/linux/3rdParty/busybox'
------initvar start done
Exporting IFS=

------initvar after export:
HISTFILESIZE='6500'
USER='dank'
MAIL='/var/mail/dank'
SSH_AGENT_PID='8207'
SHLVL='3'
HOME='/home/dank'
OLDPWD='/home/dank/wk/ixos/dap'
HUSHLOGIN='FALSE'
PS1='$ '
OPTIND='1'
PS2='> '
COLORTERM=
LOGNAME='dank'
_='wsx86/busybox'
TERM='xterm'
ICAROOT='/opt/citrix'
HISTCONTROL='ignoredups'
PPID='8331'
PATH='/usr/java/j2sdk1.4.1_01/bin:/home/dank/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/bin/X11:/usr/local/bin:/usr/local/Acrobat4/bin'
DISPLAY=':0'
HISTSIZE='6500'
LANG='C'
XAUTHORITY='/home/dank/.Xauthority'
SSH_AUTH_SOCK='/tmp/ssh-XX0engWr/agent.8179'
P4CLIENT='dank-dank'
SHELL='/bin/bash'
HZ='100'
IFS='
'
IFS='
'
IFS='
'
IFS='
'
...




More information about the busybox mailing list