]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/netinet/tcp_usrreq.c
xnu-7195.101.1.tar.gz
[apple/xnu.git] / bsd / netinet / tcp_usrreq.c
index fca0d56a6d27855550e7b22fb2602f2c13f3bd4b..861c9f71da92bd040980b634d88f920f44d446d2 100644 (file)
@@ -685,10 +685,18 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct proc *p)
                struct sockaddr_in sin;
 
                if ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0) {
-                       return EINVAL;
+                       error = EINVAL;
+                       goto out;
                }
 
                in6_sin6_2_sin(&sin, sin6p);
+               /*
+                * Must disallow TCP ``connections'' to multicast addresses.
+                */
+               if (IN_MULTICAST(ntohl(sin.sin_addr.s_addr))) {
+                       error = EAFNOSUPPORT;
+                       goto out;
+               }
                inp->inp_vflag |= INP_IPV4;
                inp->inp_vflag &= ~INP_IPV6;
                if ((error = tcp_connect(tp, (struct sockaddr *)&sin, p)) != 0) {