[lxc-devel] [lxc/master] network: fix lxc_netdev_rename_by_index()

brauner on Github lxc-bot at linuxcontainers.org
Fri Jun 14 10:40:35 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 475 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190614/7f234ba2/attachment.bin>
-------------- next part --------------
From 90d79629cb2180f6c70c47c9790fbaf8e577ab42 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 14 Jun 2019 12:39:20 +0200
Subject: [PATCH] network: fix lxc_netdev_rename_by_index()

Return an error code when the name is invalid instead of pretending that things
are fine.

Closes #3044.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/network.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/lxc/network.c b/src/lxc/network.c
index 189d92088f..0a78adc208 100644
--- a/src/lxc/network.c
+++ b/src/lxc/network.c
@@ -1160,8 +1160,10 @@ int lxc_netdev_rename_by_index(int ifindex, const char *newname)
 		return err;
 
 	len = strlen(newname);
-	if (len == 1 || len >= IFNAMSIZ)
+	if (len == 1 || len >= IFNAMSIZ) {
+		err = -EINVAL;
 		goto out;
+	}
 
 	err = -ENOMEM;
 	nlmsg = nlmsg_alloc(NLMSG_GOOD_SIZE);


More information about the lxc-devel mailing list