]> git.ipfire.org Git - thirdparty/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, 23 Aug 2018 21:13:12 +0000 (23:13 +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 bf260224a4b3c30fdb05f9e07a05d4e4f57be454..af8a0ce5a27a21a972b3191dd55d39f3667b127d 100644 (file)
@@ -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)