Thanks, Richard.  Does the following patch help?

(Disregard the spacing in original function, pushing a fix for that
separately)

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: richard -rw- weinberger <richard.weinber...@gmail.com>
Signed-off-by: Serge Hallyn <serge.hal...@ubuntu.com>
---
 src/lxc/utils.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/lxc/utils.c b/src/lxc/utils.c
index ecf9d2c..b17f51d 100644
--- a/src/lxc/utils.c
+++ b/src/lxc/utils.c
@@ -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);
-- 
1.8.1.2


------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel

Reply via email to