From: Niklas Eiling Date: Wed, 30 Mar 2016 21:28:43 +0000 (+0200) Subject: use snprintf instead of strncat X-Git-Tag: lxc-2.0.0.rc15~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F932%2Fhead;p=thirdparty%2Flxc.git use snprintf instead of strncat Signed-off-by: Niklas Eiling --- diff --git a/src/lxc/criu.c b/src/lxc/criu.c index aa874c722..52ac7b3b7 100644 --- a/src/lxc/criu.c +++ b/src/lxc/criu.c @@ -364,10 +364,13 @@ static void exec_criu(struct criu_opts *opts) buf[0] = 0; pos = 0; + for (i = 0; argv[i]; i++) { - strncat(buf, argv[i], sizeof(buf) - pos - 1); - strncat(buf, " ", sizeof(buf) - pos - 1); - pos += strlen(argv[i]); + ret = snprintf(buf + pos, sizeof(buf) - pos, "%s ", argv[i]); + if (ret < 0 || ret >= sizeof(buf) - pos) + goto err; + else + pos += ret; } INFO("execing: %s", buf);