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
This commit is contained in:
parent
9b8d05b8ac
commit
5dba6ada91
@ -597,6 +597,10 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
|||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
if ((inp->inp_vflag & INP_IPV4) == 0) {
|
||||||
|
error = EAFNOSUPPORT;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
in6_sin6_2_sin(&sin, sin6p);
|
in6_sin6_2_sin(&sin, sin6p);
|
||||||
inp->inp_vflag |= INP_IPV4;
|
inp->inp_vflag |= INP_IPV4;
|
||||||
@ -614,6 +618,11 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
|||||||
#endif
|
#endif
|
||||||
error = tp->t_fb->tfb_tcp_output(tp);
|
error = tp->t_fb->tfb_tcp_output(tp);
|
||||||
goto out;
|
goto out;
|
||||||
|
} else {
|
||||||
|
if ((inp->inp_vflag & INP_IPV6) == 0) {
|
||||||
|
error = EAFNOSUPPORT;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
inp->inp_vflag &= ~INP_IPV4;
|
inp->inp_vflag &= ~INP_IPV4;
|
||||||
|
@ -1119,6 +1119,10 @@ udp6_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
|||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
if ((inp->inp_vflag & INP_IPV4) == 0) {
|
||||||
|
error = EAFNOSUPPORT;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
if (inp->inp_faddr.s_addr != INADDR_ANY) {
|
if (inp->inp_faddr.s_addr != INADDR_ANY) {
|
||||||
error = EISCONN;
|
error = EISCONN;
|
||||||
goto out;
|
goto out;
|
||||||
@ -1136,6 +1140,11 @@ udp6_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
|
|||||||
if (error == 0)
|
if (error == 0)
|
||||||
soisconnected(so);
|
soisconnected(so);
|
||||||
goto out;
|
goto out;
|
||||||
|
} else {
|
||||||
|
if ((inp->inp_vflag & INP_IPV6) == 0) {
|
||||||
|
error = EAFNOSUPPORT;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
|
if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user