aboutsummaryrefslogtreecommitdiff
path: root/libbb/make_directory.c
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-08-24 19:51:54 +0000
committerMatt Kraai <kraai@debian.org>2001-08-24 19:51:54 +0000
commitac20ce1924a0eb563acfda6533a80701cd611bfa (patch)
tree5209668fde99a5caa4ed41d8d61c73770fcae646 /libbb/make_directory.c
parent2a953aed3831f8705444e720783ad4781904a625 (diff)
downloadbusybox-ac20ce1924a0eb563acfda6533a80701cd611bfa.tar.gz
Canonicalize dirname(3) behavior.
Diffstat (limited to 'libbb/make_directory.c')
-rw-r--r--libbb/make_directory.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libbb/make_directory.c b/libbb/make_directory.c
index 7b7fde911..a06a410d2 100644
--- a/libbb/make_directory.c
+++ b/libbb/make_directory.c
@@ -50,13 +50,17 @@ int make_directory (char *path, long mode, int flags)
if (stat (path, &st) < 0 && errno == ENOENT) {
int status;
- char *parent = dirname (path);
- mode_t mask = umask (0);
+ char *buf, *parent;
+ mode_t mask;
+
+ mask = umask (0);
umask (mask);
+ buf = xstrdup (path);
+ parent = dirname (buf);
status = make_directory (parent, (0777 & ~mask) | 0300,
FILEUTILS_RECUR);
- free (parent);
+ free (buf);
if (status < 0 || make_directory (path, mode, 0) < 0)
return -1;