diff options
author | Marcus Meissner <meissner@suse.de> | 2011-06-01 21:05:22 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-07-13 05:31:27 +0200 |
commit | bcdafe04648854ae6bb9bb2caea7f3c50d2df855 (patch) | |
tree | 3fce4f342855d5109706884e969ca85b6a0b1c9d /net/ipv4 | |
parent | 26d3cbdece9463926d553dbeed3df10af22bb161 (diff) |
net/ipv4: Check for mistakenly passed in non-IPv4 address
[ Upstream commit d0733d2e29b652b2e7b1438ececa732e4eed98eb ]
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/af_inet.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 7d12c6a9b19..8227dfaf488 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -461,6 +461,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 |