From d872d2bad5151af8be947a27c3e1f53c54d3cb61 Mon Sep 17 00:00:00 2001 From: Juha Sointusalo Date: Sun, 22 Nov 2015 19:51:06 +0200 Subject: [PATCH 1/6] lib: fix resource leak --- lib/filesys.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/filesys.cpp b/lib/filesys.cpp index a16c46a051..6535a80433 100644 --- a/lib/filesys.cpp +++ b/lib/filesys.cpp @@ -505,6 +505,7 @@ FILE* boinc_fopen(const char* path, const char* mode) { } if (f) { if (-1 == fcntl(fileno(f), F_SETFD, FD_CLOEXEC)) { + fclose(f); return 0; } } From 7ef94401162dc6f2ac9e38dce2b7ce784c2cc7b5 Mon Sep 17 00:00:00 2001 From: Juha Sointusalo Date: Sun, 22 Nov 2015 22:22:46 +0200 Subject: [PATCH 2/6] lib: add descriptions for new error numbers --- lib/str_util.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/str_util.cpp b/lib/str_util.cpp index d4af254d66..7910211126 100644 --- a/lib/str_util.cpp +++ b/lib/str_util.cpp @@ -541,6 +541,8 @@ const char* boincerror(int which_error) { case ERR_STATFS: return "statfs() failed"; case ERR_PIPE: return "pipe() failed"; case ERR_NEED_HTTPS: return "HTTPS needed"; + case ERR_CHMOD : return "chmod() failed"; + case ERR_STAT : return "stat() failed"; case HTTP_STATUS_NOT_FOUND: return "HTTP file not found"; case HTTP_STATUS_PROXY_AUTH_REQ: return "HTTP proxy authentication failure"; case HTTP_STATUS_RANGE_REQUEST_ERROR: return "HTTP range request error"; From 6ced9a08a6f60c340bb8725cb8932cdccf9e0565 Mon Sep 17 00:00:00 2001 From: Juha Sointusalo Date: Sun, 22 Nov 2015 22:50:08 +0200 Subject: [PATCH 3/6] vbox: fix memory leak in FloppyIO --- samples/vboxwrapper/floppyio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/vboxwrapper/floppyio.cpp b/samples/vboxwrapper/floppyio.cpp index 71c1e56bd4..f1d13d9fda 100644 --- a/samples/vboxwrapper/floppyio.cpp +++ b/samples/vboxwrapper/floppyio.cpp @@ -307,7 +307,7 @@ int FloppyIO::receive(string * ansBuffer) { // Copy input data to string object *ansBuffer = dataToReceive; - dataToReceive = NULL; + delete[] dataToReceive; return (int)ansBuffer->length(); } From 80135f9c95f4a1fea661c93fb6cfa25941271164 Mon Sep 17 00:00:00 2001 From: Juha Sointusalo Date: Mon, 23 Nov 2015 00:11:59 +0200 Subject: [PATCH 4/6] vbox: fix use-after-free bug in FloppyIOException --- samples/vboxwrapper/floppyio.h | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/samples/vboxwrapper/floppyio.h b/samples/vboxwrapper/floppyio.h index 5cdd702cfe..28308a2194 100644 --- a/samples/vboxwrapper/floppyio.h +++ b/samples/vboxwrapper/floppyio.h @@ -161,26 +161,35 @@ namespace FloppyIONS { int code; std::string message; + std::string full_message; // Default constructor/destructor - FloppyIOException() { this->code=0; this->message=""; }; + FloppyIOException() { + init(0, ""); + }; virtual ~FloppyIOException() throw() { }; // Get description virtual const char* what() const throw() { - static std::ostringstream oss (std::ostringstream::out); - oss << this->message << ". Error code = " << this->code; - std::string tmp = oss.str(); - return tmp.c_str(); + return full_message.c_str(); } // Change the message and return my instance // (Used for singleton format) FloppyIOException * set(int _code, std::string _message) { - this->code = _code; - this->message = _message; + init(_code, _message); return this; } + + private: + + void init(int _code, std::string _message) { + code = _code; + message = _message; + std::stringstream ss; + ss << _message << ". Error code = " << _code; + full_message = ss.str(); + } }; From fdb814979681252a813f6fa8348d6be93a4ee3a9 Mon Sep 17 00:00:00 2001 From: Juha Sointusalo Date: Mon, 23 Nov 2015 21:45:40 +0200 Subject: [PATCH 5/6] mgr: replace strncpy with strlcpy strlcpy always null terminates the dest buffer, strncpy doesn't when the buffer is too small --- clientgui/sg_ProjectPanel.cpp | 7 +++---- clientgui/sg_TaskPanel.cpp | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/clientgui/sg_ProjectPanel.cpp b/clientgui/sg_ProjectPanel.cpp index 41a22fc974..602962f532 100644 --- a/clientgui/sg_ProjectPanel.cpp +++ b/clientgui/sg_ProjectPanel.cpp @@ -29,6 +29,7 @@ #include "BOINCBaseWizard.h" #include "WizardAttach.h" #include "sg_ProjectPanel.h" +#include "str_replace.h" #if TESTBIGICONPOPUP #include "test/sah_40.xpm" #include "test/einstein_icon.xpm" @@ -250,8 +251,7 @@ void CSimpleProjectPanel::UpdateInterface() { char* ctrl_url = ((ProjectSelectionData*)m_ProjectSelectionCtrl->GetClientData(n))->project_url; if (strcmp(m_CurrentSelectedProjectURL, ctrl_url)) { b_needMenuRebuild = true; - strncpy(m_CurrentSelectedProjectURL, ctrl_url, sizeof(m_CurrentSelectedProjectURL)); - m_CurrentSelectedProjectURL[sizeof(m_CurrentSelectedProjectURL)-1] = '\0'; + strlcpy(m_CurrentSelectedProjectURL, ctrl_url, sizeof(m_CurrentSelectedProjectURL)); } PROJECT* project = pDoc->state.lookup_project(ctrl_url); @@ -459,8 +459,7 @@ void CSimpleProjectPanel::UpdateProjectList() { } #endif selData = new ProjectSelectionData; - strncpy(selData->project_url, project->master_url, sizeof(selData->project_url)); - selData->project_url[sizeof(selData->project_url)-1] = '\0'; + strlcpy(selData->project_url, project->master_url, sizeof(selData->project_url)); selData->project_files_downloaded_time = project->project_files_downloaded_time; wxBitmap* projectBM = GetProjectSpecificBitmap(selData->project_url); #if SORTPROJECTLIST diff --git a/clientgui/sg_TaskPanel.cpp b/clientgui/sg_TaskPanel.cpp index fd3878e37e..b6b64e6031 100644 --- a/clientgui/sg_TaskPanel.cpp +++ b/clientgui/sg_TaskPanel.cpp @@ -25,6 +25,7 @@ #include "sg_TaskPanel.h" #include "boinc_api.h" #include "filesys.h" +#include "str_replace.h" #define SORTTASKLIST 1 /* TRUE to sort task selection control alphabetically */ @@ -1012,10 +1013,8 @@ void CSimpleTaskPanel::UpdateTaskSelectionList(bool reskin) { selData = new TaskSelectionData; selData->result = result; - strncpy(selData->result_name, result->name, sizeof(selData->result_name)); - selData->result_name[sizeof(selData->result_name)-1] = '\0'; - strncpy(selData->project_url, result->project_url, sizeof(selData->project_url)); - selData->project_url[sizeof(selData->project_url)-1] = '\0'; + strlcpy(selData->result_name, result->name, sizeof(selData->result_name)); + strlcpy(selData->project_url, result->project_url, sizeof(selData->project_url)); selData->dotColor = -1; FindSlideShowFiles(selData); project = pDoc->state.lookup_project(result->project_url); From 2c87e5b5985feb9feaa050b73c81deb53acbb0f9 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Tue, 24 Nov 2015 03:12:16 -0800 Subject: [PATCH 6/6] Mac scr: add change I omitted from my commit 8ce413f: build 32-bit and 64-bit fat binary for compatibility with OS 10.6 and OS 10.7. This requires building with Xcode 5 or earlier, because Xcode 6 forces converting to ARC, which does not support 32-bit binaries. --- mac_build/boinc.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mac_build/boinc.xcodeproj/project.pbxproj b/mac_build/boinc.xcodeproj/project.pbxproj index 9a5ebbbbdf..341e51023a 100755 --- a/mac_build/boinc.xcodeproj/project.pbxproj +++ b/mac_build/boinc.xcodeproj/project.pbxproj @@ -3862,7 +3862,7 @@ DD9843DD09920F220090855B /* Deployment */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; CLANG_ENABLE_OBJC_ARC = NO; GCC_ENABLE_OBJC_GC = supported; HEADER_SEARCH_PATHS = ""; @@ -4034,7 +4034,7 @@ DD9E2362091CBDAE0048316E /* Development */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; CLANG_ENABLE_OBJC_ARC = NO; GCC_ENABLE_OBJC_GC = supported; HEADER_SEARCH_PATHS = "";