Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

unix,win: Check connect receives right socket type

  • Loading branch information...
erickt authored and ry committed Sep 25, 2011
1 parent 17d4686 commit c260a3964532120edcc071c22eb4bc9d8d09031d
Showing with 4 additions and 14 deletions.
  1. +2 −12 src/unix/tcp.c
  2. +2 −2 src/win/tcp.c
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}

0 comments on commit c260a39

Please sign in to comment.
You can’t perform that action at this time.