On Monday 24 November 2008 23:53, Wilmer van der Gaast wrote:
> After lots of experimenting, I finally found the bug that was
> bothering me for ages: I'm replacing components of a Netgear router
> root filesystem with newer stuff (adding IPv6 support, upgrading to a
> newer BusyBox with more applets, etc.), but whenever I tried to boot
> it with a newer Busybox shell, it doesn't boot properly.
> 
> Now I know what's going on. Some of the closed source apps that I have
> to stick to do things like:
> 
> system("start_some_broken_daemon arg1 arg2&");
> 
> to start something in the background. This ampersand isn't properly
> noticed by ash, unless there's whitespace around it (either before or
> after). As it turns out, the tokenizer sees an end of file and
> completely forget there was an &. More interesting, it will instead
> see the last token twice! See this example:
> 
> /tmp # ./ash -c '/bin/echo 1&'
> 1 1
> /tmp # ./ash -c '/bin/echo 1 &'
> 1
> /tmp # ./ash -c '/bin/echo 1& '
> 1
> 
> My knowledge on how parsers work is very weak, so I decided I'd just
> report this as a bug instead of trying to fix it myself. :-/ I saw the
> bug tracker is currently down, so I'm trying the mailing list instead.
> If there's a more suitable list to report this at, please do tell.
> Meanwhile I'll try 1.12.2, so far I didn't notice 1.13.0 was marked
> unstable...
> 
> Thanks for the awesome piece of software,

Try attached patch
--
vda
diff -d -urpN busybox.6/shell/ash.c busybox.7/shell/ash.c
--- busybox.6/shell/ash.c	2008-11-22 02:32:18.000000000 +0100
+++ busybox.7/shell/ash.c	2008-11-25 02:01:18.000000000 +0100
@@ -9314,6 +9315,9 @@ pfgets(char *line, int len)
 static void
 pungetc(void)
 {
+	/* check is needed for ash -c 'echo 5&' + BASH_COMPAT to work */
+	if (parsenleft < 0)
+		return;
 	parsenleft++;
 	parsenextc--;
 }
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to