Fix race condition in CreatePipeOverlapped

fixes #10075
This commit is contained in:
Gunnar Beutner 2016-08-10 12:12:56 +02:00
parent 39bde8078c
commit 37bd5ad800
1 changed files with 4 additions and 1 deletions

View File

@ -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);