X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=reactos%2Fdll%2Fwin32%2Fws2_32%2Fsrc%2Fsocklife.c;h=50f559f498d6a2626e86562f9c53ca4328cf324f;hp=e698dac7e80a96cee6eb5cf4fd9b2c94ec5ffa44;hb=f732630141b7ae838255f836d095946cdb419252;hpb=f78f7b3f3114248e02401f26200bd528c721e24d diff --git a/reactos/dll/win32/ws2_32/src/socklife.c b/reactos/dll/win32/ws2_32/src/socklife.c index e698dac7e80..50f559f498d 100644 --- a/reactos/dll/win32/ws2_32/src/socklife.c +++ b/reactos/dll/win32/ws2_32/src/socklife.c @@ -48,19 +48,27 @@ bind(IN SOCKET s, /* Get the Socket Context */ if ((Socket = WsSockGetSocket(s))) { - /* Make the call */ - Status = Socket->Provider->Service.lpWSPBind(s, - name, - namelen, - &ErrorCode); - /* Deference the Socket Context */ - WsSockDereference(Socket); + if (name && (namelen >= sizeof(*name))) + { + /* Make the call */ + Status = Socket->Provider->Service.lpWSPBind(s, + name, + namelen, + &ErrorCode); + /* Deference the Socket Context */ + WsSockDereference(Socket); - /* Return Provider Value */ - if (Status == ERROR_SUCCESS) return Status; + /* 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 everything seemed fine, then the WSP call failed itself */ + if (ErrorCode == NO_ERROR) ErrorCode = WSASYSCALLFAILURE; + } + else + { + /* name or namelen not valid */ + ErrorCode = WSAEFAULT; + } } else { @@ -441,8 +449,8 @@ WSASocketA(IN INT af, LPWSAPROTOCOL_INFOW p = &ProtocolInfoW; /* Convert Protocol Info to Wide */ - if (lpProtocolInfo) - { + if (lpProtocolInfo) + { /* Copy the Data */ memcpy(&ProtocolInfoW, lpProtocolInfo, @@ -455,8 +463,8 @@ WSASocketA(IN INT af, -1, ProtocolInfoW.szProtocol, sizeof(ProtocolInfoW.szProtocol) / sizeof(WCHAR)); - } - else + } + else { /* No Protocol Info Specified */ p = NULL; @@ -475,7 +483,7 @@ WSASocketA(IN INT af, * @implemented */ SOCKET -WSAAPI +WSAAPI WSASocketW(IN INT af, IN INT type, IN INT protocol, @@ -506,8 +514,8 @@ WSASocketW(IN INT af, Catalog = WsProcGetTCatalog(Process); /* Find a Provider for the Catalog ID */ - if (lpProtocolInfo) - { + if (lpProtocolInfo) + { /* Get the catalog ID */ CatalogId = lpProtocolInfo->dwCatalogEntryId; @@ -516,8 +524,8 @@ WSASocketW(IN INT af, CatalogId, &CatalogEntry); } - else - { + else + { /* No ID */ CatalogId = 0; @@ -558,8 +566,8 @@ DoLookup: WsTcEntryDereference(CatalogEntry); /* Did we fail with WSAEINPROGRESS and had no specific provider? */ - if ((Status == INVALID_SOCKET) && - (ErrorCode == WSAEINPROGRESS) && + if ((Status == INVALID_SOCKET) && + (ErrorCode == WSAEINPROGRESS) && !(lpProtocolInfo)) { /* In that case, restart the lookup from this ID */