From: Christian Brauner Date: Sat, 15 Jul 2017 13:34:21 +0000 (+0200) Subject: lxccontainer: use snprintf() X-Git-Tag: lxc-2.1.0~32^2~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90b366fc1f246ab46dc966a1f347b99a20d859c4;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 eba65a44a..663fe547d 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -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;