ipv6: Fix the return value of Set Hop-by-Hop options header with NULL data pointer

When Set Hop-by-Hop options header with NULL data 
pointer and optlen is not zero use setsockopt(),
the kernel successfully return 0 instead of 
return error EINVAL or EFAULT.

This patch fix the problem.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Yang Hongyang 2008-08-03 18:16:15 -07:00 committed by David S. Miller
parent 1730554f25
commit cfb266c0ee
1 changed files with 2 additions and 0 deletions

View File

@ -346,6 +346,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
*/ */
if (optlen == 0) if (optlen == 0)
optval = NULL; optval = NULL;
else if (optval == NULL)
goto e_inval;
else if (optlen < sizeof(struct ipv6_opt_hdr) || else if (optlen < sizeof(struct ipv6_opt_hdr) ||
optlen & 0x7 || optlen > 8 * 255) optlen & 0x7 || optlen > 8 * 255)
goto e_inval; goto e_inval;