]> 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)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 31 Jul 2017 21:34:13 +0000 (23:34 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/lxccontainer.c

index eba65a44ac0c2501e86694b4455ad6836334615c..663fe547d99aec6239699b8297ab02fe7ee927a6 100644 (file)
@@ -3354,7 +3354,11 @@ static struct lxc_container *do_lxcapi_clone(struct lxc_container *c, const char
        saved_unexp_conf = NULL;
        c->lxc_conf->unexpanded_len = saved_unexp_len;
 
-       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;