]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
log: Don't crash when name is NULL
authorStéphane Graber <stgraber@ubuntu.com>
Fri, 7 Feb 2014 14:15:39 +0000 (09:15 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 7 Feb 2014 14:15:39 +0000 (09:15 -0500)
This fixes a crash in lxc-autostart following the addition of
lxc_log_init as lxc-autostart doesn't use the name property.

Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/log.c

index 6706f907180559d2f2d86ad1843d46ecef2faafc..f0b8ff0b942d54f6bb7cb4e8a197d04820fa75e0 100644 (file)
@@ -191,6 +191,9 @@ static char *build_log_path(const char *name, const char *lxcpath)
        char *p;
        int len, ret, use_dir;
 
+       if (!name)
+               return NULL;
+
 #if USE_CONFIGPATH_LOGS
        use_dir = 1;
 #else
@@ -326,6 +329,10 @@ extern int lxc_log_init(const char *name, const char *file,
                if (geteuid())
                        return 0;
 
+               /* if no name was specified, there nothing to do */
+               if (!name)
+                       return 0;
+
                ret = -1;
 
                if (!lxcpath)