[WS2_32] Add some parameters check for getsockname. Use value size for size check instead of type in bind. ROSTEST-278

svn path=/trunk/; revision=74650
This commit is contained in:
Peter Hater 2017-05-25 14:42:24 +00:00
parent 0e96026122
commit f732630141
2 changed files with 20 additions and 12 deletions

View file

@ -217,20 +217,28 @@ getsockname(IN SOCKET s,
/* Get the Socket Context */ /* Get the Socket Context */
if ((Socket = WsSockGetSocket(s))) if ((Socket = WsSockGetSocket(s)))
{ {
/* Make the call */ if (name && namelen && (*namelen >= sizeof(*name)))
Status = Socket->Provider->Service.lpWSPGetSockName(s, {
name, /* Make the call */
namelen, Status = Socket->Provider->Service.lpWSPGetSockName(s,
&ErrorCode); name,
namelen,
&ErrorCode);
/* Deference the Socket Context */ /* Deference the Socket Context */
WsSockDereference(Socket); WsSockDereference(Socket);
/* Return Provider Value */ /* Return Provider Value */
if (Status == ERROR_SUCCESS) return Status; if (Status == ERROR_SUCCESS) return Status;
/* If everything seemed fine, then the WSP call failed itself */ /* If everything seemed fine, then the WSP call failed itself */
if (ErrorCode == NO_ERROR) ErrorCode = WSASYSCALLFAILURE; if (ErrorCode == NO_ERROR) ErrorCode = WSASYSCALLFAILURE;
}
else
{
/* name or namelen not valid */
ErrorCode = WSAEFAULT;
}
} }
else else
{ {

View file

@ -48,7 +48,7 @@ bind(IN SOCKET s,
/* Get the Socket Context */ /* Get the Socket Context */
if ((Socket = WsSockGetSocket(s))) if ((Socket = WsSockGetSocket(s)))
{ {
if (name && (namelen >= sizeof(struct sockaddr))) if (name && (namelen >= sizeof(*name)))
{ {
/* Make the call */ /* Make the call */
Status = Socket->Provider->Service.lpWSPBind(s, Status = Socket->Provider->Service.lpWSPBind(s,