]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxccontainer: create_container_dir()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 24 Feb 2018 14:30:56 +0000 (15:30 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 23 Aug 2018 20:28:53 +0000 (22:28 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/lxccontainer.c

index ac438fa35b86ff491b52ab18607597d7804171e7..d1f23c4205105d486e7fc595cfff70ecfd7705c9 100644 (file)
@@ -1157,25 +1157,27 @@ static int do_create_container_dir(const char *path, struct lxc_conf *conf)
        return ret;
 }
 
-/*
- * create the standard expected container dir
- */
+/* Create the standard expected container dir. */
 static bool create_container_dir(struct lxc_container *c)
 {
+       int ret;
+       size_t len;
        char *s;
-       int len, ret;
 
        len = strlen(c->config_path) + strlen(c->name) + 2;
        s = malloc(len);
        if (!s)
                return false;
+
        ret = snprintf(s, len, "%s/%s", c->config_path, c->name);
-       if (ret < 0 || ret >= len) {
+       if (ret < 0 || (size_t)ret >= len) {
                free(s);
                return false;
        }
+
        ret = do_create_container_dir(s, c->lxc_conf);
        free(s);
+
        return ret == 0;
 }