[PATCH] ws2_32: Check namelen before dereferencing it in TRACE (Coverity)

Marcus Meissner meissner at suse.de
Thu Feb 4 08:07:30 CST 2010


Hi,

The function later checks namelen for NULL, also the tests/ pass
in NULL for namelen, so check it before derferencing.

Ciao, Marcus
---
 dlls/ws2_32/socket.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index a9e9538..c66c853 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -1795,7 +1795,7 @@ int WINAPI WS_getpeername(SOCKET s, struct WS_sockaddr *name, int *namelen)
     int fd;
     int res;
 
-    TRACE("socket: %04lx, ptr %p, len %08x\n", s, name, *namelen);
+    TRACE("socket: %04lx, ptr %p, len %08x\n", s, name, namelen?*namelen:0);
 
     fd = get_sock_fd( s, 0, NULL );
     res = SOCKET_ERROR;
-- 
1.6.5.7



More information about the wine-patches mailing list