Skip to content

Commit

Permalink
net/ipv6: check for mistakenly passed in non-AF_INET6 sockaddrs
Browse files Browse the repository at this point in the history
Same check as for IPv4, also do for IPv6.

(If you passed in a IPv4 sockaddr_in here, the sizeof check
 in the line before would have triggered already though.)

Signed-off-by: Marcus Meissner <meissner@suse.de>
Cc: Reinhard Max <max@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Marcus Meissner authored and David S. Miller committed Jun 6, 2011
1 parent 2b22b1b commit 5a079c3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/ipv6/af_inet6.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)

if (addr_len < SIN6_LEN_RFC2133)
return -EINVAL;

if (addr->sin6_family != AF_INET6)
return -EINVAL;

addr_type = ipv6_addr_type(&addr->sin6_addr);
if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
return -EINVAL;
Expand Down

0 comments on commit 5a079c3

Please sign in to comment.