From: Tycho Andersen Date: Mon, 24 Oct 2016 22:55:49 +0000 (-0600) Subject: c/r: use snprintf to compute device name X-Git-Tag: lxc-2.1.0~290^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F1248%2Fhead;p=thirdparty%2Flxc.git c/r: use snprintf to compute device name This will never actually overflow, because %d is 32 bits and eth is 128 bytes long, but safety first :) Signed-off-by: Tycho Andersen --- diff --git a/src/lxc/criu.c b/src/lxc/criu.c index 16d439a89..094096777 100644 --- a/src/lxc/criu.c +++ b/src/lxc/criu.c @@ -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: