Skip to content

Commit

Permalink
[NET]: Ensure device name passed to SO_BINDTODEVICE is NULL terminated.
Browse files Browse the repository at this point in the history
Found by Solar Designer.

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller authored and David S. Miller committed Mar 24, 2006
1 parent a1a8fee commit f67ed26
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
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;
Expand Down

0 comments on commit f67ed26

Please sign in to comment.