[PATCH] ifplugd: repeated setenv calls
Denys Vlasenko
vda.linux at googlemail.com
Tue May 11 02:37:41 UTC 2010
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 applied typo fix, thanks!
--
vda
More information about the busybox
mailing list