[BusyBox] make_directory, dirname() bug ?

Glenn McGrath bug1 at optushome.com.au
Fri Aug 24 11:33:14 UTC 2001


Ive been working on a program to do source mirror of debian, and ive
pulled in a few libbb functions.
I think there is a bug in make_directory in the following section of code,
but im not too sure.

char *parent = dirname (path);\
mode_t mask = umask (0);
umask (mask);

if (make_directory (parent, (0777 & ~mask) | 0300, FILEUTILS_RECUR) < 0)
	return -1;
free (parent);

if (make_directory (path, mode, 0) < 0)
	return -1;


I need to remove free(parent), if i leave it the way it is the value of
path gets mangled, and the call to makedir(path, mode, 0) fails.
I dont think dirname() function is allocating new memory or not, so when
parent is freed its freeing some of path's space.

Actually checking this functions usage in busybox confirms my problems.

home:/home/bug1/lineo/busybox/busybox# ./busybox mkdir ./sdf/sdf/sdf/sdf
mkdir: Cannot create directory `./sdf/sdf/sdf/sdf': No such file or
directory

Surely if mkdir was broken it would have been picked up by now, could it
be possible that libc6 2.2.4 has changed its behaviour w.r.t dirname ?


Glenn 





More information about the busybox mailing list