Make bind(2) and connect(2) return EAFNOSUPPORT for AF_UNIX on wrong

address family.

See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191586 for the
original discussion.

Reviewed by:	terry
This commit is contained in:
Kevin Lo 2014-07-14 06:00:01 +00:00
parent 291624fdf6
commit cb7df69b7e

View File

@ -467,6 +467,9 @@ uipc_bindat(int fd, struct socket *so, struct sockaddr *nam, struct thread *td)
cap_rights_t rights;
char *buf;
if (nam->sa_family != AF_UNIX)
return (EAFNOSUPPORT);
unp = sotounpcb(so);
KASSERT(unp != NULL, ("uipc_bind: unp == NULL"));
@ -1278,6 +1281,9 @@ unp_connectat(int fd, struct socket *so, struct sockaddr *nam,
cap_rights_t rights;
int error, len;
if (nam->sa_family != AF_UNIX)
return (EAFNOSUPPORT);
UNP_LINK_WLOCK_ASSERT();
unp = sotounpcb(so);