From 1aae404a4cf7f92d4135c1b24a3b6efef6c54708 Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Tue, 18 Oct 2016 12:36:23 +0200 Subject: [PATCH] QProcess/Windows: Include PID in pipe names Although qt_create_pipe() tries again if the pipe name is already in use, it doesn't handle the case when another user has created the pipe with the name (the error is "access denied" in that case). The chance that it happens is small, but it can be entirely eliminated by including a unique part in the pipe name, in this case the PID. [ChangeLog][Windows] Named pipes internally created by QProcess now contain the PID in their name to ensure uniqueness. Change-Id: I079f1b68695c1ddea3eccad241061d11e08b60f4 Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/io/qprocess_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 05c9d6594c..fa9efcb1ce 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -102,7 +102,7 @@ static void qt_create_pipe(Q_PIPE *pipe, bool isInputPipe) // ### The user must make sure to call qsrand() to make the pipe names less predictable. // ### Replace the call to qrand() with a secure version, once we have it in Qt. _snwprintf(pipeName, sizeof(pipeName) / sizeof(pipeName[0]), - L"\\\\.\\pipe\\qt-%X", qrand()); + L"\\\\.\\pipe\\qt-%lX-%X", long(QCoreApplication::applicationPid()), qrand()); DWORD dwOpenMode = FILE_FLAG_OVERLAPPED; DWORD dwOutputBufferSize = 0;