From: Marcus Meissner Date: Thu, 2 Jun 2011 04:05:22 +0000 (-0700) Subject: net/ipv4: Check for mistakenly passed in non-IPv4 address X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=d0733d2e29b652b2e7b1438ececa732e4eed98eb;p=openwrt%2Fstaging%2Fblogic.git net/ipv4: Check for mistakenly passed in non-IPv4 address Check against mistakenly passing in IPv6 addresses (which would result in an INADDR_ANY bind) or similar incompatible sockaddrs. Signed-off-by: Marcus Meissner Cc: Reinhard Max Signed-off-by: David S. Miller --- diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index cc1463156cd0..9c1926027a26 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -465,6 +465,9 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) if (addr_len < sizeof(struct sockaddr_in)) goto out; + if (addr->sin_family != AF_INET) + goto out; + chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr); /* Not specified by any standard per-se, however it breaks too