[VODZ] mke2fs

Vladimir N. Oleynik dzo at simtreas.ru
Tue Sep 20 07:40:10 UTC 2005


Tito,

> Hi, vodz 
> in your last changes in mke2fs.c at line 797-803
> 
> 	/* Update our PATH to include /sbin  */
> 	if (oldpath) {
> 		char *newpath;
> 
> 		bb_xasprintf(&newpath, "%s:%s", PATH_SET, oldpath);
> 	} else
> 		putenv (PATH_SET);
> 
> shouldn't this be:
> 	/* Update our PATH to include /sbin  */
> 	if (oldpath) {
> 		char *newpath;
> 
> 		bb_xasprintf(&newpath, "%s:%s", PATH_SET, oldpath);
>                 putenv (newpath);
>                 if (ENABLE_FEATURE_CLEAN_UP) free(newpath);
> 	} else
> 		putenv (PATH_SET);
> 
> as newpath is not used elsewhere.

Oh, replay and replay...

$ man putenv
....
However, glibc 2.0-2.1.1 differs: a copy of the string
is used.  On the one hand this causes a memory leak,
and on the other hand it violates SUSv2.
This has been fixed in glibc2.1.2.
...

I think:
1) autoconf can`t detect this trivially
2) maintream don`t think of ENABLE_FEATURE_CLEAN_UP, and we
have problem in many place
3) quick patch may be as before return of main
if (ENABLE_FEATURE_CLEAN_UP && oldpath)
	free(newpath); /* and moved this var to top */


--w
vodz



More information about the busybox mailing list