From 095ead8051b58ec4a7aa89ad711daec15dff5f54 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Fri, 11 May 2018 00:54:47 +0200 Subject: [PATCH] network: adhere to IFNAMSIZ limit The additional \0-byte space added is not needed since IFNAMSIZ needs to include the \0-byte. Signed-off-by: Christian Brauner --- src/lxc/network.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lxc/network.c b/src/lxc/network.c index 6f379a809..8345ee394 100644 --- a/src/lxc/network.c +++ b/src/lxc/network.c @@ -2089,7 +2089,7 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna pid_t child; int bytes, pipefd[2]; char *token, *saveptr = NULL; - char netdev_link[IFNAMSIZ + 1]; + char netdev_link[IFNAMSIZ]; char buffer[MAXPATHLEN] = {0}; if (netdev->type != LXC_NET_VETH) { @@ -2127,9 +2127,9 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna } if (netdev->link[0] != '\0') - strncpy(netdev_link, netdev->link, IFNAMSIZ); + strncpy(netdev_link, netdev->link, IFNAMSIZ - 1); else - strncpy(netdev_link, "none", IFNAMSIZ); + strncpy(netdev_link, "none", IFNAMSIZ - 1); ret = snprintf(pidstr, LXC_NUMSTRLEN64, "%d", pid); if (ret < 0 || ret >= LXC_NUMSTRLEN64)