Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
unix,win: Check connect receives right socket type
  • Loading branch information
erickt authored and ry committed Sep 28, 2011
1 parent 17d4686 commit c260a39
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
14 changes: 2 additions & 12 deletions src/unix/tcp.c
Expand Up @@ -226,12 +226,7 @@ int uv_tcp_connect(uv_connect_t* req,
saved_errno = errno;
status = -1;

if (handle->type != UV_TCP) {
uv_err_new(handle->loop, EINVAL);
goto out;
}

if (address.sin_family != AF_INET) {
if (handle->type != UV_TCP || address.sin_family != AF_INET) {
uv_err_new(handle->loop, EINVAL);
goto out;
}
Expand All @@ -258,12 +253,7 @@ int uv_tcp_connect6(uv_connect_t* req,
saved_errno = errno;
status = -1;

if (handle->type != UV_TCP) {
uv_err_new(handle->loop, EINVAL);
goto out;
}

if (address.sin6_family != AF_INET6) {
if (handle->type != UV_TCP || address.sin6_family != AF_INET6) {
uv_err_new(handle->loop, EINVAL);
goto out;
}
Expand Down
4 changes: 2 additions & 2 deletions src/win/tcp.c
Expand Up @@ -484,7 +484,7 @@ int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle,
return -1;
}

if (address.sin_family != AF_INET) {
if (handle->type != UV_TCP || address.sin_family != AF_INET) {
uv_set_sys_error(loop, WSAEFAULT);
return -1;
}
Expand Down Expand Up @@ -540,7 +540,7 @@ int uv_tcp_connect6(uv_connect_t* req, uv_tcp_t* handle,
return -1;
}

if (address.sin6_family != AF_INET6) {
if (handle->type != UV_TCP || address.sin6_family != AF_INET6) {
uv_set_sys_error(loop, WSAEFAULT);
return -1;
}
Expand Down

0 comments on commit c260a39

Please sign in to comment.