[icinga-checkins] icinga.org: icinga2/master: Fix race condition in CreatePipeOverlapped

git at icinga.org git at icinga.org
Wed Aug 10 12:13:35 CEST 2016


Module: icinga2
Branch: master
Commit: 37bd5ad800e814adf84cf0b5c949b6c79b45c3db
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=37bd5ad800e814adf84cf0b5c949b6c79b45c3db

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed Aug 10 12:12:56 2016 +0200

Fix race condition in CreatePipeOverlapped

fixes #10075

---

 lib/base/process.cpp |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/base/process.cpp b/lib/base/process.cpp
index 831bf36..76628cc 100644
--- a/lib/base/process.cpp
+++ b/lib/base/process.cpp
@@ -329,13 +329,16 @@ static BOOL CreatePipeOverlapped(HANDLE *outReadPipe, HANDLE *outWritePipe,
 	if (size == 0)
 		size = 8192;
 
+	int currentIndex;
+
 	{
 		boost::mutex::scoped_lock lock(mutex);
+		currentIndex = pipeIndex;
 		pipeIndex++;
 	}
 
 	char pipeName[128];
-	sprintf(pipeName, "\\\\.\\Pipe\\OverlappedPipe.%d.%d", (int)GetCurrentProcessId(), pipeIndex);
+	sprintf(pipeName, "\\\\.\\Pipe\\OverlappedPipe.%d.%d", (int)GetCurrentProcessId(), currentIndex);
 
 	*outReadPipe = CreateNamedPipe(pipeName, PIPE_ACCESS_INBOUND | readMode,
 	    PIPE_TYPE_BYTE | PIPE_WAIT, 1, size, size, 60 * 1000, securityAttributes);



More information about the icinga-checkins mailing list