On Wednesday 20 February 2008 00:01, Cristian Ionescu-Idbohrn wrote:
> On Tue, 19 Feb 2008, Denys Vlasenko wrote:
> 
> > On Tuesday 19 February 2008 22:12, Cristian Ionescu-Idbohrn wrote:
> > > On Tue, 19 Feb 2008, Denys Vlasenko wrote:
> > >
> > > > Is this on x86 with .config I sent?
> > >
> > > No.  It's my config.  Comes in an attachment.
> >
> > I can reproduce it.
> 
> Alright.
> 
> > But when I flip
> >
> > # CONFIG_ASH_MAIL is not set
> >
> > to Y, it disappears. Does it happen on your side?
> 
> Nope.  No difference (see attched result).

Yes. We were using uninitialized data on stack.
Using chkmail() happened to give me "good" values.

Fix is attached. Please test.
--
vda
diff -d -urpN busybox.1/shell/ash.c busybox.2/shell/ash.c
--- busybox.1/shell/ash.c	2008-02-17 16:13:14.000000000 +0100
+++ busybox.2/shell/ash.c	2008-02-20 00:25:57.000000000 +0100
@@ -1785,22 +1785,26 @@ static struct globals_var *const ptr_to_
 	} \
 } while (0)
 
-#define vifs    varinit[0]
+#define vifs      varinit[0]
 #if ENABLE_ASH_MAIL
-#define vmail   (&vifs)[1]
-#define vmpath  (&vmail)[1]
+# define vmail    (&vifs)[1]
+# define vmpath   (&vmail)[1]
+# define vpath    (&vmpath)[1]
 #else
-#define vmpath  vifs
+# define vpath    (&vifs)[1]
 #endif
-#define vpath   (&vmpath)[1]
-#define vps1    (&vpath)[1]
-#define vps2    (&vps1)[1]
-#define vps4    (&vps2)[1]
-#define voptind (&vps4)[1]
+#define vps1      (&vpath)[1]
+#define vps2      (&vps1)[1]
+#define vps4      (&vps2)[1]
 #if ENABLE_ASH_GETOPTS
-#define vrandom (&voptind)[1]
+# define voptind  (&vps4)[1]
+# if ENABLE_ASH_RANDOM_SUPPORT
+#  define vrandom (&voptind)[1]
+# endif
 #else
-#define vrandom (&vps4)[1]
+# if ENABLE_ASH_RANDOM_SUPPORT
+#  define vrandom (&vps4)[1]
+# endif
 #endif
 
 /*
@@ -1810,15 +1814,18 @@ static struct globals_var *const ptr_to_
  */
 #define ifsval()        (vifs.text + 4)
 #define ifsset()        ((vifs.flags & VUNSET) == 0)
-#define mailval()       (vmail.text + 5)
-#define mpathval()      (vmpath.text + 9)
+#if ENABLE_ASH_MAIL
+# define mailval()      (vmail.text + 5)
+# define mpathval()     (vmpath.text + 9)
+# define mpathset()     ((vmpath.flags & VUNSET) == 0)
+#endif
 #define pathval()       (vpath.text + 5)
 #define ps1val()        (vps1.text + 4)
 #define ps2val()        (vps2.text + 4)
 #define ps4val()        (vps4.text + 4)
-#define optindval()     (voptind.text + 7)
-
-#define mpathset()      ((vmpath.flags & VUNSET) == 0)
+#if ENABLE_ASH_GETOPTS
+# define optindval()    (voptind.text + 7)
+#endif
 
 
 #define is_name(c)      ((c) == '_' || isalpha((unsigned char)(c)))
@@ -5912,8 +5919,9 @@ varvalue(char *name, int varflags, int f
 			unsigned name_len = (strchrnul(name, '=') - name) + 1;
 			p = NULL;
 			do {
-				char *str = var_str_list->text;
-				char *eq = strchr(str, '=');
+				char *str, *eq;
+				str = var_str_list->text;
+				eq = strchr(str, '=');
 				if (!eq) /* stop at first non-assignment */
 					break;
 				eq++;
@@ -7677,6 +7685,7 @@ evalfor(union node *n, int flags)
 	struct stackmark smark;
 
 	setstackmark(&smark);
+	arglist.list = NULL;
 	arglist.lastp = &arglist.list;
 	for (argp = n->nfor.args; argp; argp = argp->narg.next) {
 		expandarg(argp, &arglist, EXP_FULL | EXP_TILDE | EXP_RECORD);
@@ -7716,6 +7725,7 @@ evalcase(union node *n, int flags)
 	struct stackmark smark;
 
 	setstackmark(&smark);
+	arglist.list = NULL;
 	arglist.lastp = &arglist.list;
 	expandarg(n->ncase.expr, &arglist, EXP_TILDE);
 	exitstatus = 0;
@@ -7777,7 +7787,7 @@ expredir(union node *n)
 	for (redir = n; redir; redir = redir->nfile.next) {
 		struct arglist fn;
 
-		memset(&fn, 0, sizeof(fn));
+		fn.list = NULL;
 		fn.lastp = &fn.list;
 		switch (redir->type) {
 		case NFROMTO:
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to