On Tue, 19 Feb 2008, Denys Vlasenko wrote:
> I think str can be NULL. Possible fix:
>
>
> - char *str = var_str_list->text;
> - char *eq = strchr(str, '=');
> + char *eq;
> + char *str = var_str_list->text;
> + if (!str) break;
> + eq = strchr(str, '=');
Doesn't look that way :( Seems to bail out on this line (see attached
diff).
eq = strchr(str, '=');
str is pointing to something, but that doesn't seem to be the right
thing (uninitialized?).
# for B in $VAR;do echo $B;done
sh: LINE 5907
sh: LINE 5914: name='VAR=', name_len=4
sh: LINE 5916
sh: LINE 5920
sh: LINE 5923
Cheers,
--
Cristian--- shell/ash.c 2008-02-19 13:19:32.000000000 +0100
+++ shell/ash.c 2008-02-19 15:47:23.000000000 +0100
@@ -5904,32 +5904,52 @@
p = num ? shellparam.p[num - 1] : arg0;
goto value;
default:
+ bb_error_msg("LINE %d", __LINE__);
/* NB: name has form "VAR=..." */
/* "A=a B=$A" case: var_str_list is a list of "A=a" strings
* which should be considered before we check variables. */
if (var_str_list) {
unsigned name_len = (strchrnul(name, '=') - name) + 1;
+ bb_error_msg("LINE %d: name='%s', name_len=%u", __LINE__, name, name_len);
p = NULL;
+ bb_error_msg("LINE %d", __LINE__);
do {
+ char *eq;
char *str = var_str_list->text;
- char *eq = strchr(str, '=');
+ bb_error_msg("LINE %d", __LINE__);
+ if (!str)
+ break;
+ bb_error_msg("LINE %d", __LINE__);
+ eq = strchr(str, '=');
+ bb_error_msg("LINE %d", __LINE__);
if (!eq) /* stop at first non-assignment */
break;
+ bb_error_msg("LINE %d", __LINE__);
eq++;
+ bb_error_msg("LINE %d", __LINE__);
if (name_len == (eq - str)
&& strncmp(str, name, name_len) == 0) {
+ bb_error_msg("LINE %d", __LINE__);
p = eq;
/* goto value; - WRONG! */
/* think "A=1 A=2 B=$A" */
+ bb_error_msg("LINE %d", __LINE__);
}
+ bb_error_msg("LINE %d", __LINE__);
var_str_list = var_str_list->next;
+ bb_error_msg("LINE %d", __LINE__);
} while (var_str_list);
+ bb_error_msg("LINE %d", __LINE__);
if (p)
goto value;
+ bb_error_msg("LINE %d", __LINE__);
}
+ bb_error_msg("LINE %d", __LINE__);
p = lookupvar(name);
+ bb_error_msg("LINE %d", __LINE__);
value:
+ bb_error_msg("LINE %d", __LINE__);
if (!p)
return -1;
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox