From f9ddd20c2d51475f82e563f26232b9944ebba799 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 3 Jun 2014 15:13:02 +0200 Subject: swrap: fix AF_UNSPEC special case in swrap_bind() Signed-off-by: Michael Adam Reviewed-by: Andreas Schneider --- lib/socket_wrapper/socket_wrapper.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c index 0303b210434..b66b9510f47 100644 --- a/lib/socket_wrapper/socket_wrapper.c +++ b/lib/socket_wrapper/socket_wrapper.c @@ -1309,6 +1309,26 @@ static int sockaddr_convert_to_un(struct socket_info *si, #endif switch (in_addr->sa_family) { + case AF_UNSPEC: { + struct sockaddr_in *sin; + if (si->family != AF_INET) { + break; + } + if (in_len < sizeof(struct sockaddr_in)) { + break; + } + sin = (struct sockaddr_in *)in_addr; + if(sin->sin_addr.s_addr != htonl(INADDR_ANY)) { + break; + } + + /* + * Note: in the special case of AF_UNSPEC and INADDR_ANY, + * AF_UNSPEC is mapped to AF_INET and must be treated here. + */ + + /* FALL THROUGH */ + } case AF_INET: #ifdef HAVE_IPV6 case AF_INET6: -- cgit