mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +00:00
[MSAFD]
- Handle the case (again) where we get passed an invalid lpErrno pointer to a WSP function - Fixes some crashes I encountered when running Opera 9 svn path=/trunk/; revision=47863
This commit is contained in:
parent
b51143af5f
commit
91aa625c40
2 changed files with 37 additions and 22 deletions
|
@ -382,24 +382,6 @@ TranslateNtStatusError(NTSTATUS Status)
|
|||
}
|
||||
}
|
||||
|
||||
DWORD MsafdReturnWithErrno(NTSTATUS Status,
|
||||
LPINT Errno,
|
||||
DWORD Received,
|
||||
LPDWORD ReturnedBytes)
|
||||
{
|
||||
*Errno = TranslateNtStatusError(Status);
|
||||
|
||||
if (ReturnedBytes)
|
||||
{
|
||||
if (!*Errno)
|
||||
*ReturnedBytes = Received;
|
||||
else
|
||||
*ReturnedBytes = 0;
|
||||
}
|
||||
|
||||
return *Errno ? SOCKET_ERROR : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* FUNCTION: Closes an open socket
|
||||
* ARGUMENTS:
|
||||
|
@ -2088,7 +2070,16 @@ WSPSetSockOpt(
|
|||
}
|
||||
|
||||
|
||||
/* FIXME: We should handle some cases here */
|
||||
/* FIXME: We should handle some more cases here */
|
||||
if (level == SOL_SOCKET)
|
||||
{
|
||||
switch (optname)
|
||||
{
|
||||
case SO_BROADCAST:
|
||||
Socket->SharedData.Broadcast = (*optval != 0) ? 1 : 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*lpErrno = Socket->HelperData->WSHSetSocketInformation(Socket->HelperContext,
|
||||
|
|
|
@ -467,11 +467,35 @@ SockReenableAsyncSelectEvent (
|
|||
IN PSOCKET_INFORMATION Socket,
|
||||
IN ULONG Event
|
||||
);
|
||||
|
||||
DWORD MsafdReturnWithErrno( NTSTATUS Status, LPINT Errno, DWORD Received,
|
||||
LPDWORD ReturnedBytes );
|
||||
|
||||
typedef VOID (*PASYNC_COMPLETION_ROUTINE)(PVOID Context, PIO_STATUS_BLOCK IoStatusBlock);
|
||||
|
||||
DWORD
|
||||
FORCEINLINE
|
||||
MsafdReturnWithErrno(NTSTATUS Status,
|
||||
LPINT Errno,
|
||||
DWORD Received,
|
||||
LPDWORD ReturnedBytes)
|
||||
{
|
||||
if (Errno)
|
||||
{
|
||||
*Errno = TranslateNtStatusError(Status);
|
||||
|
||||
if (ReturnedBytes)
|
||||
*ReturnedBytes = (*Errno == 0) ? Received : 0;
|
||||
|
||||
return (*Errno == 0) ? 0 : SOCKET_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgPrint("%s: Received invalid lpErrno pointer!\n", __FUNCTION__);
|
||||
|
||||
if (ReturnedBytes)
|
||||
*ReturnedBytes = (Status == STATUS_SUCCESS) ? Received : 0;
|
||||
|
||||
return (Status == STATUS_SUCCESS) ? 0 : SOCKET_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __MSAFD_H */
|
||||
|
||||
|
|
Loading…
Reference in a new issue