net: Zero terminate ifr_name in dev_ifname().
authorDavid S. Miller <davem@davemloft.net>
Wed, 19 Jul 2017 20:33:24 +0000 (13:33 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 19 Jul 2017 20:33:24 +0000 (13:33 -0700)
The ifr.ifr_name is passed around and assumed to be NULL terminated.

Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/dev_ioctl.c

index 7657ad6bc13d14e16f1775824d229ce8337c21c0..06b147d7d9e2e7d8d305dd9b173d9bc1a7e9a676 100644 (file)
@@ -28,6 +28,7 @@ static int dev_ifname(struct net *net, struct ifreq __user *arg)
 
        if (copy_from_user(&ifr, arg, sizeof(struct ifreq)))
                return -EFAULT;
+       ifr.ifr_name[IFNAMSIZ-1] = 0;
 
        error = netdev_get_name(net, ifr.ifr_name, ifr.ifr_ifindex);
        if (error)