svn commit: r318649 - in head/sys: netinet netinet6
Michael Tuexen
tuexen at FreeBSD.org
Mon May 22 15:29:12 UTC 2017
Author: tuexen
Date: Mon May 22 15:29:10 2017
New Revision: 318649
URL: https://svnweb.freebsd.org/changeset/base/318649
Log:
The connect() system call should return -1 and set errno to EAFNOSUPPORT
if it is called on a TCP socket
* with an IPv6 address and the socket is bound to an
IPv4-mapped IPv6 address.
* with an IPv4-mapped IPv6 address and the socket is bound to an
IPv6 address.
Thanks to Jonathan T. Leighton for reporting this issue.
Reviewed by: bz gnn
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D9163
Modified:
head/sys/netinet/tcp_usrreq.c
head/sys/netinet6/udp6_usrreq.c
Modified: head/sys/netinet/tcp_usrreq.c
==============================================================================
--- head/sys/netinet/tcp_usrreq.c Mon May 22 15:12:49 2017 (r318648)
+++ head/sys/netinet/tcp_usrreq.c Mon May 22 15:29:10 2017 (r318649)
@@ -597,6 +597,10 @@ tcp6_usr_connect(struct socket *so, stru
error = EINVAL;
goto out;
}
+ if ((inp->inp_vflag & INP_IPV4) == 0) {
+ error = EAFNOSUPPORT;
+ goto out;
+ }
in6_sin6_2_sin(&sin, sin6p);
inp->inp_vflag |= INP_IPV4;
@@ -614,6 +618,11 @@ tcp6_usr_connect(struct socket *so, stru
#endif
error = tp->t_fb->tfb_tcp_output(tp);
goto out;
+ } else {
+ if ((inp->inp_vflag & INP_IPV6) == 0) {
+ error = EAFNOSUPPORT;
+ goto out;
+ }
}
#endif
inp->inp_vflag &= ~INP_IPV4;
Modified: head/sys/netinet6/udp6_usrreq.c
==============================================================================
--- head/sys/netinet6/udp6_usrreq.c Mon May 22 15:12:49 2017 (r318648)
+++ head/sys/netinet6/udp6_usrreq.c Mon May 22 15:29:10 2017 (r318649)
@@ -1119,6 +1119,10 @@ udp6_connect(struct socket *so, struct s
error = EINVAL;
goto out;
}
+ if ((inp->inp_vflag & INP_IPV4) == 0) {
+ error = EAFNOSUPPORT;
+ goto out;
+ }
if (inp->inp_faddr.s_addr != INADDR_ANY) {
error = EISCONN;
goto out;
@@ -1136,6 +1140,11 @@ udp6_connect(struct socket *so, struct s
if (error == 0)
soisconnected(so);
goto out;
+ } else {
+ if ((inp->inp_vflag & INP_IPV6) == 0) {
+ error = EAFNOSUPPORT;
+ goto out;
+ }
}
#endif
if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
More information about the svn-src-head
mailing list