[lxc-devel] [lxc/master] gcc-8: silence
brauner on Github
lxc-bot at linuxcontainers.org
Thu May 10 22:57:14 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180510/be1d76e0/attachment.bin>
-------------- next part --------------
From def4def6fd9df15dbb1f3ea107b92ab0ce96d909 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 11 May 2018 00:52:33 +0200
Subject: [PATCH 1/2] network: silence gcc-8
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
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 <christian.brauner at ubuntu.com>
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 <christian.brauner at ubuntu.com>
---
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)
More information about the lxc-devel
mailing list