connect() now checks socket family

This commit is contained in:
Joseph Henry
2015-10-13 19:27:19 -04:00
parent 1fd04557c7
commit 71c6ec71e5
3 changed files with 12 additions and 7 deletions

View File

@@ -607,6 +607,9 @@ int socket(SOCKET_SIG)
connect() intercept function */
int connect(CONNECT_SIG)
{
struct sockaddr_in *connaddr;
connaddr = (struct sockaddr_in *) __addr;
#ifdef CHECKS
/* Check that this is a valid fd */
if(fcntl(__fd, F_GETFD) < 0) {
@@ -620,6 +623,11 @@ int connect(CONNECT_SIG)
errno = ENOTSOCK;
return -1;
}
/* Check family */
if (connaddr->sin_family < 0 || connaddr->sin_family >= NPROTO){
errno = EAFNOSUPPORT;
return -1;
}
/* FIXME: Check that address is in user space, return EFAULT ? */
#endif
@@ -637,9 +645,6 @@ int connect(CONNECT_SIG)
return(realconnect(__fd, __addr, __len));
}
struct sockaddr_in *connaddr;
connaddr = (struct sockaddr_in *) __addr;
if(__addr != NULL && (connaddr->sin_family == AF_LOCAL
|| connaddr->sin_family == PF_NETLINK
|| connaddr->sin_family == AF_NETLINK