[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 1a7e6ea..e110b90 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;