mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-10 17:04:51 +00:00
c/r: use sizeof instead of magic numbers
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
fed29fad60
commit
e311a56235
@ -3639,16 +3639,16 @@ static void exec_criu(struct criu_opts *opts)
|
|||||||
struct lxc_netdev *n = it->elem;
|
struct lxc_netdev *n = it->elem;
|
||||||
|
|
||||||
if (n->name) {
|
if (n->name) {
|
||||||
if (strlen(n->name) >= 128)
|
if (strlen(n->name) >= sizeof(eth))
|
||||||
goto err;
|
goto err;
|
||||||
strncpy(eth, n->name, 128);
|
strncpy(eth, n->name, sizeof(eth));
|
||||||
} else
|
} else
|
||||||
sprintf(eth, "eth%d", netnr);
|
sprintf(eth, "eth%d", netnr);
|
||||||
|
|
||||||
veth = n->priv.veth_attr.pair;
|
veth = n->priv.veth_attr.pair;
|
||||||
|
|
||||||
ret = snprintf(buf, 257, "%s=%s", eth, veth);
|
ret = snprintf(buf, sizeof(buf), "%s=%s", eth, veth);
|
||||||
if (ret < 0 || ret >= 257)
|
if (ret < 0 || ret >= sizeof(buf))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
/* final NULL and --veth-pair eth0=vethASDF */
|
/* final NULL and --veth-pair eth0=vethASDF */
|
||||||
|
Loading…
Reference in New Issue
Block a user