X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=reactos%2Fdll%2Fwin32%2Fws2_32%2Fsrc%2Fsockctrl.c;h=458aafec077f512a286fe0875c0bc297cf6705a2;hp=2414b032315c2b5dece32a0c75a848da3a9b4a32;hb=1bde2edfcb7779f2aa4c067d8770681403af4249;hpb=fbfe11f633e8b0035a433e1d7d19566d7b89024c diff --git a/reactos/dll/win32/ws2_32/src/sockctrl.c b/reactos/dll/win32/ws2_32/src/sockctrl.c index 2414b032315..458aafec077 100644 --- a/reactos/dll/win32/ws2_32/src/sockctrl.c +++ b/reactos/dll/win32/ws2_32/src/sockctrl.c @@ -39,54 +39,62 @@ connect(IN SOCKET s, /* Get the Socket Context */ if ((Socket = WsSockGetSocket(s))) { - while (TRUE) + if (!IsBadReadPtr(name, sizeof(struct sockaddr))) { - /* Make the call */ - Status = Socket->Provider->Service.lpWSPConnect(s, - name, - namelen, - NULL, - NULL, - NULL, - NULL, - &ErrorCode); - - /* Check if error code was due to the host not being found */ - if ((Status == SOCKET_ERROR) && - ((ErrorCode == WSAEHOSTUNREACH) || - (ErrorCode == WSAENETUNREACH))) + while (TRUE) { - /* Check if we can try again */ - if (TryAgain) - { - /* Save the old error code */ - OldErrorCode = ErrorCode; - - /* Make sure we don't retry 3 times */ - TryAgain = FALSE; + /* Make the call */ + Status = Socket->Provider->Service.lpWSPConnect(s, + name, + namelen, + NULL, + NULL, + NULL, + NULL, + &ErrorCode); - /* Make the RAS Auto-dial attempt */ - if (WSAttemptAutodialAddr(name, namelen)) continue; - } - else + /* Check if error code was due to the host not being found */ + if ((Status == SOCKET_ERROR) && + ((ErrorCode == WSAEHOSTUNREACH) || + (ErrorCode == WSAENETUNREACH))) { - /* Restore the error code */ - ErrorCode = OldErrorCode; + /* Check if we can try again */ + if (TryAgain) + { + /* Save the old error code */ + OldErrorCode = ErrorCode; + + /* Make sure we don't retry 3 times */ + TryAgain = FALSE; + + /* Make the RAS Auto-dial attempt */ + if (WSAttemptAutodialAddr(name, namelen)) continue; + } + else + { + /* Restore the error code */ + ErrorCode = OldErrorCode; + } } - } - /* Break out of the loop */ - break; - } + /* Break out of the loop */ + break; + } - /* Deference the Socket Context */ - WsSockDereference(Socket); + /* Deference the Socket Context */ + WsSockDereference(Socket); - /* Return Provider Value */ - if (Status == ERROR_SUCCESS) return Status; + /* Return Provider Value */ + if (Status == ERROR_SUCCESS) return Status; - /* If everything seemed fine, then the WSP call failed itself */ - if (ErrorCode == NO_ERROR) ErrorCode = WSASYSCALLFAILURE; + /* If everything seemed fine, then the WSP call failed itself */ + if (ErrorCode == NO_ERROR) ErrorCode = WSASYSCALLFAILURE; + } + else + { + /* Invalid user pointer */ + ErrorCode = WSAEFAULT; + } } else {