net/ipv4: Check for mistakenly passed in non-IPv4 address
authorMarcus Meissner <meissner@suse.de>
Thu, 2 Jun 2011 04:05:22 +0000 (21:05 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 2 Jun 2011 04:05:22 +0000 (21:05 -0700)
Check against mistakenly passing in IPv6 addresses (which would result
in an INADDR_ANY bind) or similar incompatible sockaddrs.

Signed-off-by: Marcus Meissner <meissner@suse.de>
Cc: Reinhard Max <max@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/af_inet.c

index cc1463156cd037ad08b6a2f637c90b4d43fc5e7a..9c1926027a268162a3c37374a5f3397661c6dba6 100644 (file)
@@ -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