httpd: memory hole in function addEnv() and more
Richard Kojedzinszky
krichy at tvnetwork.hu
Mon Sep 5 09:42:19 UTC 2005
On Mon, 5 Sep 2005, Vladimir N. Oleynik wrote:
> Dirk,
>
> > Let's have a look into addEnv() from httpd.c
> >
> > static void addEnv(const char *name_before_underline,
> > const char *name_after_underline, const char *value)
> > {
> > char *s = NULL;
> > const char *underline;
> >
> > if (!value)
> > value = "";
> > underline = *name_after_underline ? "_" : "";
> > asprintf(&s, "%s%s%s=%s", name_before_underline, underline,
> > name_after_underline, value);
> > if(s) {
> > putenv(s);
> > }
> > }
> >
> > ************
> >
> > 1.) memory hole
> >
> > Them memory alloced by asprintf() is never free'd.
> > Solution: insert free(s) behind putenv(s).
>
> No.
> man putenv()
> see libc incompatibility memory allocated sections.
And as I saw, it is always called in the cgi child, so there is no memory
leak in long time.
Correct me if i am wrong.
Regards,
Richard Kojedzinszky
More information about the busybox
mailing list