Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a079c30 authored by Marcus Meissner's avatar Marcus Meissner Committed by David S. Miller
Browse files

net/ipv6: check for mistakenly passed in non-AF_INET6 sockaddrs



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: default avatarMarcus Meissner <meissner@suse.de>
Cc: Reinhard Max <max@suse.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2b22b1b1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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;