]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
c/r: use snprintf to compute device name 1248/head
authorTycho Andersen <tycho.andersen@canonical.com>
Mon, 24 Oct 2016 22:55:49 +0000 (16:55 -0600)
committerTycho Andersen <tycho.andersen@canonical.com>
Mon, 24 Oct 2016 22:58:06 +0000 (16:58 -0600)
This will never actually overflow, because %d is 32 bits and eth is 128
bytes long, but safety first :)

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
src/lxc/criu.c

index 16d439a89a3bfee44a88998ac183a4bd9e270ce7..094096777cb63b1cc4942a21882c4870641dd2b9 100644 (file)
@@ -443,8 +443,11 @@ static void exec_criu(struct criu_opts *opts)
                                if (strlen(n->name) >= sizeof(eth))
                                        goto err;
                                strncpy(eth, n->name, sizeof(eth));
-                       } else
-                               sprintf(eth, "eth%d", netnr);
+                       } else {
+                               ret = snprintf(eth, sizeof(eth), "eth%d", netnr);
+                               if (ret < 0 || ret >= sizeof(eth))
+                                       goto err;
+                       }
 
                        switch (n->type) {
                        case LXC_NET_VETH: