svn commit: [25867] trunk/busybox/shell
vapier at busybox.net
vapier at busybox.net
Sat Mar 28 21:06:23 UTC 2009
Author: vapier
Date: 2009-03-28 21:06:22 +0000 (Sat, 28 Mar 2009)
New Revision: 25867
Log:
do not let handle_dollar() accept vars that start with a digit
Modified:
trunk/busybox/shell/hush.c
Changeset:
Modified: trunk/busybox/shell/hush.c
===================================================================
--- trunk/busybox/shell/hush.c 2009-03-28 20:01:58 UTC (rev 25866)
+++ trunk/busybox/shell/hush.c 2009-03-28 21:06:22 UTC (rev 25867)
@@ -1647,6 +1647,7 @@
/* lookup the variable in question */
if (isdigit(var[0])) {
+ /* handle_dollar() should have vetted var for us */
i = xatoi_u(var);
if (i < G.global_argc)
val = G.global_argv[i];
@@ -3726,22 +3727,33 @@
case '@': /* args */
goto make_one_char_var;
case '{': {
- bool first_char;
+ bool first_char, all_digits;
o_addchr(dest, SPECIAL_VAR_SYMBOL);
i_getch(input);
/* XXX maybe someone will try to escape the '}' */
expansion = 0;
first_char = true;
+ all_digits = false;
while (1) {
ch = i_getch(input);
if (ch == '}')
break;
- if (ch == '#' && first_char)
- /* ${#var}: length of var contents */;
+ if (first_char) {
+ if (ch == '#')
+ /* ${#var}: length of var contents */
+ goto char_ok;
+ else if (isdigit(ch)) {
+ all_digits = true;
+ goto char_ok;
+ }
+ }
- else if (expansion < 2 && !isalnum(ch) && ch != '_') {
+ if (expansion < 2 &&
+ ((all_digits && !isdigit(ch)) ||
+ (!all_digits && !isalnum(ch) && ch != '_')))
+ {
/* handle parameter expansions
* http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02
*/
@@ -3782,6 +3794,8 @@
return 1;
}
}
+
+ char_ok:
debug_printf_parse(": '%c'\n", ch);
o_addchr(dest, ch | quote_mask);
quote_mask = 0;
More information about the busybox-cvs
mailing list