- 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:
Cameron Gutman 2010-06-27 17:21:03 +00:00
parent b51143af5f
commit 91aa625c40
2 changed files with 37 additions and 22 deletions

View file

@ -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,

View file

@ -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 */