From: Christian Brauner Date: Sat, 15 Jul 2017 13:34:21 +0000 (+0200) Subject: lxccontainer: use snprintf() X-Git-Tag: lxc-1.0.11~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1e22e81a66e395677e8a63c922039a259aa404f;p=thirdparty%2Flxc.git lxccontainer: use snprintf() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index e7c9113b4..3963a3eec 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -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;