From 2628a6a3a6ddc03cfc811bdb41e421e0e4e2364f Mon Sep 17 00:00:00 2001 From: Martin Date: Sat, 2 Nov 2013 22:59:27 +0100 Subject: [PATCH] Fixed coverity issues --- LoadbalancerClient.cpp | 1 + Server.cpp | 3 ++- ServerLinux.cpp | 1 + downloadplugin/download2.cpp | 5 ++++- file_linux.cpp | 2 +- httpserver/HTTPProxy.cpp | 2 +- md5.cpp | 2 ++ urbackupserver/server_get.cpp | 3 +++ 8 files changed, 15 insertions(+), 4 deletions(-) diff --git a/LoadbalancerClient.cpp b/LoadbalancerClient.cpp index f42d7de5..33a18b8b 100644 --- a/LoadbalancerClient.cpp +++ b/LoadbalancerClient.cpp @@ -82,6 +82,7 @@ void CLoadbalancerClient::operator ()(void) if( err==-1 ) { Server->Log("Could not connect to LoadBalancer", LL_ERROR ); + closesocket(s); return; } diff --git a/Server.cpp b/Server.cpp index 96b6276d..1cc52154 100644 --- a/Server.cpp +++ b/Server.cpp @@ -918,6 +918,7 @@ void CServer::StartCustomStreamService(IService *pService, std::string pServiceN IPipe* CServer::ConnectStream(std::string pServer, unsigned short pPort, unsigned int pTimeoutms) { sockaddr_in server; + memset(&server, 0, sizeof(server)); LookupBlocking(pServer, &server.sin_addr); server.sin_port=htons(pPort); server.sin_family=AF_INET; @@ -1176,7 +1177,7 @@ void thread_helper_f(IThread *t) } #else #ifndef _WIN32 -void *thread_helper_f(void * t) +void thread_helper_f(void * t) { IThread *tmp=(IThread*)t; (*tmp)(); diff --git a/ServerLinux.cpp b/ServerLinux.cpp index 0e99bf72..5556212c 100644 --- a/ServerLinux.cpp +++ b/ServerLinux.cpp @@ -61,4 +61,5 @@ void CServer::UnloadDLLs2(void) int CServer::WriteDump(void* pExceptionPointers) { + return 0; } diff --git a/downloadplugin/download2.cpp b/downloadplugin/download2.cpp index 4739ac10..5c10f12d 100644 --- a/downloadplugin/download2.cpp +++ b/downloadplugin/download2.cpp @@ -66,7 +66,7 @@ bool DownloadfileThreaded(std::string url,std::string filename, IPipe *pipe, std int Cs; string ret; - sockaddr_in addr; + fstream out; out.open(filename.c_str(),ios::out|ios::binary); if(out.is_open()==false) @@ -115,6 +115,9 @@ bool DownloadfileThreaded(std::string url,std::string filename, IPipe *pipe, std wd.addUChar(DL2_INFO_RESOLVING); pipe->Write(wd.getDataPtr(), wd.getDataSize()); } + + sockaddr_in addr; + memset(&addr, 0, sizeof(addr)); addr.sin_family=AF_INET; if(proxy=="") diff --git a/file_linux.cpp b/file_linux.cpp index 8d611150..c54fa91d 100644 --- a/file_linux.cpp +++ b/file_linux.cpp @@ -51,7 +51,7 @@ File::File() bool File::Open(std::wstring pfn, int mode) { fn=pfn; - int flags; + int flags=0; mode_t imode=S_IRWXU|S_IRWXG; if( mode==MODE_READ || mode==MODE_READ_DEVICE || mode==MODE_READ_SEQUENTIAL || mode==MODE_READ_SEQUENTIAL_BACKUP) { diff --git a/httpserver/HTTPProxy.cpp b/httpserver/HTTPProxy.cpp index b5b4d887..fc09fb28 100644 --- a/httpserver/HTTPProxy.cpp +++ b/httpserver/HTTPProxy.cpp @@ -125,7 +125,7 @@ void CHTTPProxy::operator()(void) { const char *vv="HTTP/1.0 200 OK\r\nContent-Type: video/mpeg\r\n\r\n"; size_t vv_len=strlen(vv); - char *msg=new char[vv_len]; + char *msg=new char[vv_len+1]; memcpy(msg, vv, vv_len); CBuffer b(msg, vv_len); b.rcount=new int; diff --git a/md5.cpp b/md5.cpp index 5756391c..e02de676 100644 --- a/md5.cpp +++ b/md5.cpp @@ -269,6 +269,7 @@ unsigned char *MD5::raw_digest(){ if (!finalized){ cerr << "MD5::raw_digest: Can't get digest if you haven't "<< "finalized the digest!" <