diff options
author | tuexen <tuexen@FreeBSD.org> | 2017-06-01 10:03:41 +0000 |
---|---|---|
committer | tuexen <tuexen@FreeBSD.org> | 2017-06-01 10:03:41 +0000 |
commit | c5ed50cbb819bcac3a2b8deb80c7b5ad14b32746 (patch) | |
tree | 017ed1ac05a9ddc218e23d3896d820d3f7bb6607 /sys/netinet6 | |
parent | f8f15c3dc0453ea0ed276dcc50c61a9d79cde955 (diff) | |
download | FreeBSD-src-c5ed50cbb819bcac3a2b8deb80c7b5ad14b32746.zip FreeBSD-src-c5ed50cbb819bcac3a2b8deb80c7b5ad14b32746.tar.gz |
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
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/udp6_usrreq.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index cc10527..56faf5a 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -1104,6 +1104,10 @@ udp6_connect(struct socket *so, struct sockaddr *nam, struct thread *td) 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, struct thread *td) 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)) { |