]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxccontainer: use snprintf()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 15 Jul 2017 13:34:21 +0000 (15:34 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 17 Aug 2017 19:32:13 +0000 (15:32 -0400)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/lxccontainer.c

index e7c9113b4e5ed065af0f0f8bd71c9d942cda5b12..3963a3eecf1f8fc17c77d4987026af30c34f8d16 100644 (file)
@@ -2679,7 +2679,11 @@ static struct lxc_container *lxcapi_clone(struct lxc_container *c, const char *n
        fclose(fout);
        c->lxc_conf->rootfs.path = origroot;
 
-       sprintf(newpath, "%s/%s/rootfs", lxcpath, newname);
+       ret = snprintf(newpath, MAXPATHLEN, "%s/%s/rootfs", lxcpath, newname);
+       if (ret < 0 || ret >= MAXPATHLEN) {
+               SYSERROR("clone: failed making rootfs pathname");
+               goto out;
+       }
        if (mkdir(newpath, 0755) < 0) {
                SYSERROR("error creating %s", newpath);
                goto out;