svn commit: r319411 - in stable/11/sys: netinet netinet6
Michael Tuexen
tuexen at FreeBSD.org
Thu Jun 1 10:03:43 UTC 2017
Author: tuexen
Date: Thu Jun 1 10:03:41 2017
New Revision: 319411
URL: https://svnweb.freebsd.org/changeset/base/319411
Log:
MFC r318649:
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
Differential Revision: https://reviews.freebsd.org/D9163
Modified:
stable/11/sys/netinet/tcp_usrreq.c
stable/11/sys/netinet6/udp6_usrreq.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/netinet/tcp_usrreq.c
==============================================================================
--- stable/11/sys/netinet/tcp_usrreq.c Thu Jun 1 09:53:55 2017 (r319410)
+++ stable/11/sys/netinet/tcp_usrreq.c Thu Jun 1 10:03:41 2017 (r319411)
@@ -597,6 +597,10 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *n
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, struct sockaddr *n
#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: stable/11/sys/netinet6/udp6_usrreq.c
==============================================================================
--- stable/11/sys/netinet6/udp6_usrreq.c Thu Jun 1 09:53:55 2017 (r319410)
+++ stable/11/sys/netinet6/udp6_usrreq.c Thu Jun 1 10:03:41 2017 (r319411)
@@ -1104,6 +1104,10 @@ udp6_connect(struct socket *so, struct sockaddr *nam,
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;
@@ -1121,6 +1125,11 @@ udp6_connect(struct socket *so, struct sockaddr *nam,
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-stable
mailing list