use snprintf instead of strncat

Signed-off-by: Niklas Eiling <niklas.eiling@rwth-aachen.de>
This commit is contained in:
Niklas Eiling 2016-03-30 23:28:43 +02:00
parent a17fa3c081
commit 72a30576da

View File

@ -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);