Commit 5edf0f4d authored by David S. Miller's avatar David S. Miller Committed by Adrian Bunk

[IPV6]: Handle np->opt being NULL in ipv6_getsockopt_sticky(). (CVE-2007-1000)

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarAdrian Bunk <bunk@stusta.de>
parent e62a305a
......@@ -631,11 +631,15 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname,
return -EINVAL;
}
static int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_opt_hdr *hdr,
static int ipv6_getsockopt_sticky(struct sock *sk, struct ipv6_txoptions *opt,
char __user *optval, int len)
{
if (!hdr)
struct ipv6_opt_hdr *hdr;
if (!opt || !opt->hopopt)
return 0;
hdr = opt->hopopt;
len = min_t(int, len, ipv6_optlen(hdr));
if (copy_to_user(optval, hdr, ipv6_optlen(hdr)))
return -EFAULT;
......@@ -779,7 +783,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname,
{
lock_sock(sk);
len = ipv6_getsockopt_sticky(sk, np->opt->hopopt,
len = ipv6_getsockopt_sticky(sk, np->opt,
optval, len);
release_sock(sk);
return put_user(len, optlen);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment