[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    =?us-ascii?Q?Re=3A=20=5BPATCH=5D=20ifplugd=3A=20repeated=20setenv=20calls?=
From:       <xmaks () email ! cz>
Date:       2010-05-14 11:14:40
Message-ID: 5187.1767.2401-26466-906929188-1273835680 () email ! cz
[Download RAW message or body]

> On Monday 10 May 2010 21:55, Maksym Kryzhanovskyy wrote:
> > > ifplugd.setenv2.patch:
> > > 
> > > +       env = getenv(name);
> > > +       unsetenv(name);
> > > +       if (env != NULL) {
> > > +               free(env - strlen(name) - 1);
> > > +       }
> > > 
> > > Why do you think getenv result is safe to be freed?
> > > Initial program environment is NOT malloced,
> > > you must not free it, this may SEGV!
> > 
> > But when getenv returns non-null pointer it means
> > that the environment is allocated and var is found
> > in the table, or not?
> 
> No. Initial environment (one which porgram inherits from parent
> via execve() syscall ('e' in execve means "environment"!) is not
> malloced. It just copied by kernel in tha same memory page(s)
> where argv[] vector is stored.
> 

I absorbed it, thanks.

> 
> I applied typo fix, thanks!
> 
> -- 
> vda
> 
> 
> 

Max.
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic