Author: cgutman Date: Sun Jun 27 17:21:03 2010 New Revision: 47863
URL: http://svn.reactos.org/svn/reactos?rev=47863&view=rev Log: [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
Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c trunk/reactos/dll/win32/msafd/msafd.h
Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/dllmai... ============================================================================== --- trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] Sun Jun 27 17:21:03 2010 @@ -380,24 +380,6 @@ DbgPrint("MSAFD: Unhandled NTSTATUS value: 0x%x\n", Status); return WSAENETDOWN; } -} - -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; }
/* @@ -2088,7 +2070,16 @@ }
- /* 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,
Modified: trunk/reactos/dll/win32/msafd/msafd.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/msafd.h?rev... ============================================================================== --- trunk/reactos/dll/win32/msafd/msafd.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/msafd/msafd.h [iso-8859-1] Sun Jun 27 17:21:03 2010 @@ -467,11 +467,35 @@ IN PSOCKET_INFORMATION Socket, IN ULONG Event ); + +typedef VOID (*PASYNC_COMPLETION_ROUTINE)(PVOID Context, PIO_STATUS_BLOCK IoStatusBlock);
-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 */