]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
use snprintf instead of strncat 932/head
authorNiklas Eiling <niklas.eiling@rwth-aachen.de>
Wed, 30 Mar 2016 21:28:43 +0000 (23:28 +0200)
committerNiklas Eiling <niklas.eiling@rwth-aachen.de>
Wed, 30 Mar 2016 21:34:37 +0000 (23:34 +0200)
Signed-off-by: Niklas Eiling <niklas.eiling@rwth-aachen.de>
src/lxc/criu.c

index aa874c7229b905e8824527d460a1421c11be0214..52ac7b3b77e4a9de0cf24a5e3605e11db3d5fdab 100644 (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);