Author: phater
Date: Thu May 25 14:42:24 2017
New Revision: 74650
URL:
http://svn.reactos.org/svn/reactos?rev=74650&view=rev
Log:
[WS2_32] Add some parameters check for getsockname. Use value size for size check instead
of type in bind. ROSTEST-278
Modified:
trunk/reactos/dll/win32/ws2_32/src/sockctrl.c
trunk/reactos/dll/win32/ws2_32/src/socklife.c
Modified: trunk/reactos/dll/win32/ws2_32/src/sockctrl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/src/sockc…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32/src/sockctrl.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32/src/sockctrl.c [iso-8859-1] Thu May 25 14:42:24 2017
@@ -217,20 +217,28 @@
/* Get the Socket Context */
if ((Socket = WsSockGetSocket(s)))
{
- /* Make the call */
- Status = Socket->Provider->Service.lpWSPGetSockName(s,
- name,
- namelen,
- &ErrorCode);
-
- /* 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;
+ if (name && namelen && (*namelen >= sizeof(*name)))
+ {
+ /* Make the call */
+ Status = Socket->Provider->Service.lpWSPGetSockName(s,
+ name,
+ namelen,
+ &ErrorCode);
+
+ /* 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
+ {
+ /* name or namelen not valid */
+ ErrorCode = WSAEFAULT;
+ }
}
else
{
Modified: trunk/reactos/dll/win32/ws2_32/src/socklife.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/src/sockl…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32/src/socklife.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32/src/socklife.c [iso-8859-1] Thu May 25 14:42:24 2017
@@ -48,7 +48,7 @@
/* Get the Socket Context */
if ((Socket = WsSockGetSocket(s)))
{
- if (name && (namelen >= sizeof(struct sockaddr)))
+ if (name && (namelen >= sizeof(*name)))
{
/* Make the call */
Status = Socket->Provider->Service.lpWSPBind(s,