The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/2314

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Christian Brauner <[email protected]>
From def4def6fd9df15dbb1f3ea107b92ab0ce96d909 Mon Sep 17 00:00:00 2001
From: Christian Brauner <[email protected]>
Date: Fri, 11 May 2018 00:52:33 +0200
Subject: [PATCH 1/2] network: silence gcc-8

Signed-off-by: Christian Brauner <[email protected]>
---
 src/lxc/network.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lxc/network.c b/src/lxc/network.c
index 04944811c..6f379a809 100644
--- a/src/lxc/network.c
+++ b/src/lxc/network.c
@@ -2178,8 +2178,8 @@ static int lxc_create_network_unpriv_exec(const char 
*lxcpath, const char *lxcna
                return -1;
        }
 
-       memset(netdev->name, 0, IFNAMSIZ + 1);
-       strncpy(netdev->name, token, IFNAMSIZ);
+       memset(netdev->name, 0, IFNAMSIZ);
+       memcpy(netdev->name, token, IFNAMSIZ - 1);
 
        /* netdev->ifindex */
        token = strtok_r(NULL, ":", &saveptr);

From 095ead8051b58ec4a7aa89ad711daec15dff5f54 Mon Sep 17 00:00:00 2001
From: Christian Brauner <[email protected]>
Date: Fri, 11 May 2018 00:54:47 +0200
Subject: [PATCH 2/2] 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 <[email protected]>
---
 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)
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to