Skip to content

Commit

Permalink
net/ipv4: Check for mistakenly passed in non-IPv4 address
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Marcus Meissner authored and David S. Miller committed Jun 2, 2011
1 parent 948252c commit d0733d2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/ipv4/af_inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d0733d2

Please sign in to comment.