mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 22:36:23 +00:00
[WS2_32]
Don't pass a null ptr at MSAFD to avoid dereference. Fixes crash in ws2_32:sock svn path=/trunk/; revision=74992
This commit is contained in:
parent
fbfe11f633
commit
1bde2edfcb
1 changed files with 48 additions and 40 deletions
|
@ -39,54 +39,62 @@ connect(IN SOCKET s,
|
||||||
/* Get the Socket Context */
|
/* Get the Socket Context */
|
||||||
if ((Socket = WsSockGetSocket(s)))
|
if ((Socket = WsSockGetSocket(s)))
|
||||||
{
|
{
|
||||||
while (TRUE)
|
if (!IsBadReadPtr(name, sizeof(struct sockaddr)))
|
||||||
{
|
{
|
||||||
/* Make the call */
|
while (TRUE)
|
||||||
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)))
|
|
||||||
{
|
{
|
||||||
/* Check if we can try again */
|
/* Make the call */
|
||||||
if (TryAgain)
|
Status = Socket->Provider->Service.lpWSPConnect(s,
|
||||||
{
|
name,
|
||||||
/* Save the old error code */
|
namelen,
|
||||||
OldErrorCode = ErrorCode;
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&ErrorCode);
|
||||||
|
|
||||||
/* Make sure we don't retry 3 times */
|
/* Check if error code was due to the host not being found */
|
||||||
TryAgain = FALSE;
|
if ((Status == SOCKET_ERROR) &&
|
||||||
|
((ErrorCode == WSAEHOSTUNREACH) ||
|
||||||
/* Make the RAS Auto-dial attempt */
|
(ErrorCode == WSAENETUNREACH)))
|
||||||
if (WSAttemptAutodialAddr(name, namelen)) continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/* Restore the error code */
|
/* Check if we can try again */
|
||||||
ErrorCode = OldErrorCode;
|
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 */
|
/* Deference the Socket Context */
|
||||||
break;
|
WsSockDereference(Socket);
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Invalid user pointer */
|
||||||
|
ErrorCode = WSAEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deference the Socket Context */
|
|
||||||
WsSockDereference(Socket);
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue