提交 f67ed26f 编写于 作者: D David S. Miller 提交者: David S. Miller

[NET]: Ensure device name passed to SO_BINDTODEVICE is NULL terminated.

Found by Solar Designer.
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 a1a8feed
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册