Skip to content

Commit

Permalink
[IPV6]: Fix the return value of get destination options with NULL dat…
Browse files Browse the repository at this point in the history
…a pointer

If we pass NULL data buffer to getsockopt(), it will return 0,
and the option length is set to -EFAULT:
    getsockopt(sk, IPPROTO_IPV6, IPV6_DSTOPTS, NULL, &len);

This is because ipv6_getsockopt_sticky() will return -EFAULT or
-EINVAL if some error occur.

This patch fix this problem.

Signed-off-by: Yang Hongyang <[email protected]>
Signed-off-by: YOSHIFUJI Hideaki <[email protected]>
  • Loading branch information
macrosheep authored and yoshfuji committed Jun 4, 2008
1 parent 4bed72e commit 05335c2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/ipv6/ipv6_sockglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,9 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
len = ipv6_getsockopt_sticky(sk, np->opt,
optname, optval, len);
release_sock(sk);
/* check if ipv6_getsockopt_sticky() returns err code */
if (len < 0)
return len;
return put_user(len, optlen);
}

Expand Down

0 comments on commit 05335c2

Please sign in to comment.