From 998cabafac9ea836d1176a1650b2e1338e9a9e38 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Wed, 18 Dec 2013 08:26:16 -0800 Subject: [PATCH] - a few more coverity reported fixes --- source/shared_lib/sources/feathery_ftp/ftpTargetPosix.c | 2 +- source/shared_lib/sources/platform/posix/socket.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/shared_lib/sources/feathery_ftp/ftpTargetPosix.c b/source/shared_lib/sources/feathery_ftp/ftpTargetPosix.c index 1f39eba9..80585525 100644 --- a/source/shared_lib/sources/feathery_ftp/ftpTargetPosix.c +++ b/source/shared_lib/sources/feathery_ftp/ftpTargetPosix.c @@ -458,7 +458,7 @@ socket_t ftpAcceptServerConnection(socket_t server, ip_t *remoteIP, port_t *remo if(!ownIp) // kennen wir schon die eigene IP? { len = sizeof(sockinfo); - if(getsockname(clientSocket, (struct sockaddr *)&sockinfo, &len)) + if(clientSocket >= 0 && getsockname(clientSocket, (struct sockaddr *)&sockinfo, &len)) { if(VERBOSE_MODE_ENABLED) printf("getsockname error\n"); } diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index f12a140f..8aa8f0c4 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -724,7 +724,7 @@ std::vector Socket::getLocalIPAddressList() { int result_ifaddrr = ioctl(fd, SIOCGIFADDR, &ifr); ioctl(fd, SIOCGIFFLAGS, &ifrA); - close(fd); + if(fd >= 0) close(fd); if(result_ifaddrr >= 0) { struct sockaddr_in *pSockAddr = (struct sockaddr_in *)&ifr.ifr_addr; @@ -2147,10 +2147,10 @@ void BroadCastClientSocketThread::execute() { } #ifndef WIN32 - ::close(bcfd); + if(bcfd >= 0) ::close(bcfd); bcfd = INVALID_SOCKET; #else - ::closesocket(bcfd); + if(bcfd >= 0) ::closesocket(bcfd); bcfd = INVALID_SOCKET; #endif