Commit 883f4a1e by Serge Hallyn

mkdir_p: account for '//foo/bar'

As Richard reported, dirname('//') returns //. But mkdir_p only stops when called with '/', resulting in infinite recursion when given a pathname '//foo/bar'. Reported-by: 's avatarrichard -rw- weinberger <richard.weinberger@gmail.com> Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent ce4c4ca4
......@@ -95,12 +95,21 @@ extern int get_u16(unsigned short *val, const char *arg, int base)
return 0;
}
static int is_all_slashes(char *path)
{
while (*path && *path == '/')
path++;
if (*path)
return 0;
return 1;
}
extern int mkdir_p(char *dir, mode_t mode)
{
int ret;
char *d;
if (!strcmp(dir, "/"))
if (is_all_slashes(dir))
return 0;
d = strdup(dir);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment