From ff01c2a19657a234bdc489b86648f655cbe4d99c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Hentschel?= Date: Sun, 19 Jul 2015 23:11:52 +0200 Subject: [PATCH] ws2_32: Pass correct buffer length to WS_inet_ntop (Coverity). --- dlls/ws2_32/socket.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 4fe3a0b2a94..d7e5276da3c 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -7663,12 +7663,14 @@ INT WINAPI WSAAddressToStringA( LPSOCKADDR sockaddr, DWORD len, case WS_AF_INET6: { struct WS_sockaddr_in6 *sockaddr6 = (LPSOCKADDR_IN6) sockaddr; + size_t slen; buffer[0] = 0; if (len < sizeof(SOCKADDR_IN6)) return SOCKET_ERROR; if ((sockaddr6->sin6_port)) strcpy(buffer, "["); - if (!WS_inet_ntop(WS_AF_INET6, &sockaddr6->sin6_addr, buffer+strlen(buffer), sizeof(buffer))) + slen = strlen(buffer); + if (!WS_inet_ntop(WS_AF_INET6, &sockaddr6->sin6_addr, &buffer[slen], sizeof(buffer) - slen)) { SetLastError(WSAEINVAL); return SOCKET_ERROR;