Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[muen/linux.git] / net / sctp / socket.c
index 2a2e094560dedafa043b7374941e82559e47a739..80835ac26d2c3ce6559f75aaaa0b315fb77d9adf 100644 (file)
@@ -357,11 +357,14 @@ static struct sctp_af *sctp_sockaddr_af(struct sctp_sock *opt,
        if (!opt->pf->af_supported(addr->sa.sa_family, opt))
                return NULL;
 
-       /* V4 mapped address are really of AF_INET family */
-       if (addr->sa.sa_family == AF_INET6 &&
-           ipv6_addr_v4mapped(&addr->v6.sin6_addr) &&
-           !opt->pf->af_supported(AF_INET, opt))
-               return NULL;
+       if (addr->sa.sa_family == AF_INET6) {
+               if (len < SIN6_LEN_RFC2133)
+                       return NULL;
+               /* V4 mapped address are really of AF_INET family */
+               if (ipv6_addr_v4mapped(&addr->v6.sin6_addr) &&
+                   !opt->pf->af_supported(AF_INET, opt))
+                       return NULL;
+       }
 
        /* If we get this far, af is valid. */
        af = sctp_get_af_specific(addr->sa.sa_family);