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: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 04cf9156
...@@ -2008,7 +2008,7 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna ...@@ -2008,7 +2008,7 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
pid_t child; pid_t child;
int bytes, pipefd[2]; int bytes, pipefd[2];
char *token, *saveptr = NULL; char *token, *saveptr = NULL;
char netdev_link[IFNAMSIZ + 1]; char netdev_link[IFNAMSIZ];
char buffer[MAXPATHLEN] = {0}; char buffer[MAXPATHLEN] = {0};
if (netdev->type != LXC_NET_VETH) { if (netdev->type != LXC_NET_VETH) {
...@@ -2046,9 +2046,9 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna ...@@ -2046,9 +2046,9 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
} }
if (netdev->link[0] != '\0') if (netdev->link[0] != '\0')
strncpy(netdev_link, netdev->link, IFNAMSIZ); strncpy(netdev_link, netdev->link, IFNAMSIZ - 1);
else else
strncpy(netdev_link, "none", IFNAMSIZ); strncpy(netdev_link, "none", IFNAMSIZ - 1);
ret = snprintf(pidstr, LXC_NUMSTRLEN64, "%d", pid); ret = snprintf(pidstr, LXC_NUMSTRLEN64, "%d", pid);
if (ret < 0 || ret >= LXC_NUMSTRLEN64) if (ret < 0 || ret >= LXC_NUMSTRLEN64)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment