swrap: fix AF_UNSPEC special case in swrap_bind()
authorMichael Adam <obnox@samba.org>
Fri, 30 May 2014 11:21:00 +0000 (13:21 +0200)
committerMichael Adam <obnox@samba.org>
Sun, 1 Jun 2014 08:03:17 +0000 (10:03 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
src/socket_wrapper.c

index 0303b21043462a054fbcbc98c170f186be1d54db..b66b9510f471631b3274639d64fe7587849a4d13 100644 (file)
@@ -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: