]> git.proxmox.com Git - mirror_lxc.git/commitdiff
network: adhere to IFNAMSIZ limit
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 10 May 2018 22:54:47 +0000 (00:54 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 10 May 2018 22:55:39 +0000 (00:55 +0200)
The additional \0-byte space added is not needed since IFNAMSIZ needs to
include the \0-byte.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/network.c

index 6f379a809173fee814a6ce81e6ee8456d4c93fb3..8345ee3940424f1605f8d4ff5ea12a6a3ec34b68 100644 (file)
@@ -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)