svn commit: [25932] trunk/busybox/shell

vda at busybox.net vda at busybox.net
Thu Apr 2 16:55:38 UTC 2009


Author: vda
Date: 2009-04-02 16:55:38 +0000 (Thu, 02 Apr 2009)
New Revision: 25932

Log:
hush: do not inadvertently parse $((1 + "22")) as ok.
 -20 bytes code size



Modified:
   trunk/busybox/shell/hush.c


Changeset:
Modified: trunk/busybox/shell/hush.c
===================================================================
--- trunk/busybox/shell/hush.c	2009-04-02 16:31:29 UTC (rev 25931)
+++ trunk/busybox/shell/hush.c	2009-04-02 16:55:38 UTC (rev 25932)
@@ -432,7 +432,7 @@
 	CHAR_ORDINARY           = 0,
 	CHAR_ORDINARY_IF_QUOTED = 1, /* example: *, # */
 	CHAR_IFS                = 2, /* treated as ordinary if quoted */
-	CHAR_SPECIAL            = 3, /* example: $ */
+	CHAR_SPECIAL            = 3, /* \, $, ", maybe ` */
 };
 
 enum {
@@ -4160,17 +4160,7 @@
 	}
 	debug_printf_parse(": ch=%c (%d) m=%d quote=%d\n",
 					ch, ch, m, dest->o_quote);
-	if (m != CHAR_SPECIAL) {
-		o_addQchr(dest, ch);
-		if ((dest->o_assignment == MAYBE_ASSIGNMENT
-		    || dest->o_assignment == WORD_IS_KEYWORD)
-		 && ch == '='
-		 && is_assignment(dest->data)
-		) {
-			dest->o_assignment = DEFINITELY_ASSIGNMENT;
-		}
-		goto again;
-	}
+	/* Basically, checking every CHAR_SPECIAL char except '"' */
 	if (ch == '\\') {
 		if (next == EOF) {
 			syntax("\\<eof>");
@@ -4208,9 +4198,17 @@
 		add_till_backquote(dest, input);
 		o_addchr(dest, SPECIAL_VAR_SYMBOL);
 		//debug_printf_subst("SUBST RES3 '%s'\n", dest->data + pos);
-		/* fall through */
+		goto again;
 	}
 #endif
+	o_addQchr(dest, ch);
+	if (ch == '='
+	 && (dest->o_assignment == MAYBE_ASSIGNMENT
+	    || dest->o_assignment == WORD_IS_KEYWORD)
+	 && is_assignment(dest->data)
+	) {
+		dest->o_assignment = DEFINITELY_ASSIGNMENT;
+	}
 	goto again;
 }
 



More information about the busybox-cvs mailing list