make-w32
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cleansing the environment automatically


From: Eli Zaretskii
Subject: Re: Cleansing the environment automatically
Date: Sat, 19 Jan 2008 12:16:11 +0200

[Moved to make-w32, as this is now a discussion about a bug.]

> Date: Sat, 19 Jan 2008 11:14:36 +0200
> From: Eli Zaretskii <address@hidden>
> Cc: address@hidden
> 
> > Date: Sat, 19 Jan 2008 04:26:49 +0000
> > From: Greg Chicares <address@hidden>
> > Cc: David Wuertele <address@hidden>, address@hidden
> > 
> > On 2008-01-19 03:17Z, Paul Smith wrote:
> > > On Sat, 2008-01-19 at 01:09 +0000, David Wuertele wrote:
> > >> I always try to create a more strict configuration hygiene by
> > >> cleansing the environment using "env -i" at the beginning of each
> > >> command.
> > [...]
> > >         unexport $(.VARIABLES)
> > 
> > I tried that with this testcase, using a msw binary I'd built
> > myself from FSF make-3.81 sources, and got a segfault:
> > 
> > C:/tmp[0]$cat env_i.make
> > unexport $(.VARIABLES)
> > 
> > all:
> >     @echo xyzzy is $$xyzzy
> > C:/tmp[0]$make -f env_i.make
> > \usr\bin\make.EXE: Interrupt/Exception caught (code = 0xc0000005, addr = 
> > 0x419fc0)
> 
> I see this on Windows as well, but on GNU/Linux the above testcase
> does not cause a crash.  I will try to look into this

The reason is the fact that on Windows, $SHELL is not normally set in
the environment when Make is invoked.  This causes shell_var to remain
unset, and "unexport" exposes this bug because it tries to use the
value of shell_var.

I propose the following fix; if no one objects in a week, I will
install it in CVS.


2008-01-19  Eli Zaretskii  <address@hidden>

        * variable.c (target_environment): Don't use shell_var if its
        `value' field is NULL.


--- variable.c~4        2007-10-13 12:15:27.995750000 +0200
+++ variable.c  2008-01-19 12:00:18.101750000 +0200
@@ -916,15 +916,18 @@ target_environment (struct file *file)
                break;
 
              case v_noexport:
-                /* If this is the SHELL variable and it's not exported, then
-                   add the value from our original environment.  */
-                if (streq (v->name, "SHELL"))
-                  {
-                    extern struct variable shell_var;
-                    v = &shell_var;
-                    break;
-                  }
-                continue;
+               {
+                 /* If this is the SHELL variable and it's not exported,
+                    then add the value from our original environment, if
+                    the original environment defined a value for SHELL.  */
+                 extern struct variable shell_var;
+                 if (streq (v->name, "SHELL") && shell_var.value)
+                   {
+                     v = &shell_var;
+                     break;
+                   }
+                 continue;
+               }
 
              case v_ifset:
                if (v->origin == o_default)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]