From: Christian Brauner Date: Thu, 10 May 2018 22:54:47 +0000 (+0200) Subject: network: adhere to IFNAMSIZ limit X-Git-Tag: lxc-2.0.10~147 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c414d6fd0e06212cacfd05e2c44fe75e9aba25b0;p=thirdparty%2Flxc.git 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 --- diff --git a/src/lxc/network.c b/src/lxc/network.c index bf260224a..af8a0ce5a 100644 --- a/src/lxc/network.c +++ b/src/lxc/network.c @@ -2008,7 +2008,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) { @@ -2046,9 +2046,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)