diff options
author | Rob Landley <rob@landley.net> | 2014-03-24 06:26:49 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2014-03-24 06:26:49 -0500 |
commit | 02f5a30ec0acf6c42441e5b06fb3ab41f629952a (patch) | |
tree | 0c4dd7cd7acc4500302f88fb5f784110773cdd33 | |
parent | 64f61640880011b991931ac30371719edd88e65d (diff) | |
download | toybox-02f5a30ec0acf6c42441e5b06fb3ab41f629952a.tar.gz toybox-02f5a30ec0acf6c42441e5b06fb3ab41f629952a.tar.bz2 toybox-02f5a30ec0acf6c42441e5b06fb3ab41f629952a.zip |
Fix mkdir -p with absolute paths.
Stripping leading / is not the right thing to do there.
Broken when the code moved to lib and was genericized for use elsewhere.
-rw-r--r-- | lib/lib.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -135,15 +135,12 @@ int mkpathat(int atfd, char *dir, mode_t lastmode, int flags) return 1; } - // Skip leading / of absolute paths - while (*dir == '/') dir++; - - for (s=dir; ;s++) { + for (s = dir; ;s++) { char save = 0; mode_t mode = (0777&~toys.old_umask)|0300; - // Skip leading / of absolute paths. - if (*s == '/' && (flags&2)) { + // find next '/', but don't try to mkdir "" at start of absolute path + if (*s == '/' && (flags&2) && s != dir) { save = *s; *s = 0; } else if (*s) continue; |