[NET]: Ensure device name passed to SO_BINDTODEVICE is NULL terminated.
authorDavid S. Miller <davem@davemloft.net>
Fri, 24 Mar 2006 06:47:40 +0000 (22:47 -0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Fri, 24 Mar 2006 23:44:59 +0000 (15:44 -0800)
Found by Solar Designer.

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

index 1a7e6eac90b04f89efca8620ed64686496a8e647..e110b9004147b4418391467a4b31715a5dc2902a 100644 (file)
@@ -404,8 +404,9 @@ set_rcvbuf:
                        if (!valbool) {
                                sk->sk_bound_dev_if = 0;
                        } else {
-                               if (optlen > IFNAMSIZ) 
-                                       optlen = IFNAMSIZ; 
+                               if (optlen > IFNAMSIZ - 1)
+                                       optlen = IFNAMSIZ - 1;
+                               memset(devname, 0, sizeof(devname));
                                if (copy_from_user(devname, optval, optlen)) {
                                        ret = -EFAULT;
                                        break;