Author: phater
Date: Fri May 26 10:32:01 2017
New Revision: 74668
URL:
http://svn.reactos.org/svn/reactos?rev=74668&view=rev
Log:
[MSAFD] Add some parameters check for WSPBind. Inspired by results of bind test
Modified:
trunk/reactos/dll/win32/msafd/misc/dllmain.c
Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/dllma…
==============================================================================
--- trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] Fri May 26 10:32:01 2017
@@ -860,6 +860,27 @@
if (lpErrno) *lpErrno = WSAENOTSOCK;
return SOCKET_ERROR;
}
+ if (Socket->SharedData->State != SocketOpen)
+ {
+ if (lpErrno) *lpErrno = WSAEINVAL;
+ return SOCKET_ERROR;
+ }
+ if (!SocketAddress || SocketAddressLength <
Socket->SharedData->SizeOfLocalAddress)
+ {
+ if (lpErrno) *lpErrno = WSAEINVAL;
+ return SOCKET_ERROR;
+ }
+
+ /* Get Address Information */
+ Socket->HelperData->WSHGetSockaddrType ((PSOCKADDR)SocketAddress,
+ SocketAddressLength,
+ &SocketInfo);
+
+ if (SocketInfo.AddressInfo == SockaddrAddressInfoBroadcast &&
!Socket->SharedData->Broadcast)
+ {
+ if (lpErrno) *lpErrno = WSAEADDRNOTAVAIL;
+ return SOCKET_ERROR;
+ }
Status = NtCreateEvent(&SockEvent,
EVENT_ALL_ACCESS,
@@ -886,11 +907,6 @@
RtlCopyMemory (BindData->Address.Address[0].Address,
SocketAddress->sa_data,
SocketAddressLength - sizeof(SocketAddress->sa_family));
-
- /* Get Address Information */
- Socket->HelperData->WSHGetSockaddrType ((PSOCKADDR)SocketAddress,
- SocketAddressLength,
- &SocketInfo);
/* Set the Share Type */
if (Socket->SharedData->ExclusiveAddressUse)