vlan: use alloca to get rid of IFNAMSIZE in vlan_dev_set_name()
authorHans Dedecker <dedeckeh@gmail.com>
Mon, 16 Jul 2018 21:03:25 +0000 (23:03 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Tue, 17 Jul 2018 21:12:03 +0000 (23:12 +0200)
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
vlan.c

diff --git a/vlan.c b/vlan.c
index 84befc9..221c79c 100644 (file)
--- a/vlan.c
+++ b/vlan.c
@@ -63,10 +63,12 @@ static int vlan_set_device_state(struct device *dev, bool up)
 
 static void vlan_dev_set_name(struct vlan_device *vldev, struct device *dev)
 {
-       char name[IFNAMSIZ];
+       char *name;
 
+       name = alloca(strlen(dev->ifname) + sizeof(".2147483647\0"));
        vldev->dev.hidden = dev->hidden;
-       snprintf(name, IFNAMSIZ, "%s.%d", dev->ifname, vldev->id);
+       sprintf(name, "%s.%d", dev->ifname, vldev->id);
+
        device_set_ifname(&vldev->dev, name);
 }