From f8d6a164deeee500556b78a72f744ac5bce2226f Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 20 Feb 2012 12:31:37 +0100 Subject: [PATCH] fix QProcess for Windows XP CreateNamedPipe supports the flag PIPE_REJECT_REMOTE_CLIENTS since Windows Vista. On earlier Windows versions the system call would fail with ERROR_INVALID_PARAMETER. This does not open a security hole on Windows XP as there can be only one pipe instance. Change-Id: I5a1c7fdf756678009857317c7b563c884afeef2c Reviewed-by: Friedemann Kleint --- src/corelib/io/qprocess_win.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 51f34a61a6..a52fd46c97 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -85,10 +85,13 @@ static void qt_create_pipe(Q_PIPE *pipe, bool isInputPipe) // ### Replace the call to qrand() with a secure version, once we have it in Qt. swprintf(pipeName, L"\\\\.\\pipe\\qt-%X", qrand()); + DWORD dwPipeFlags = PIPE_TYPE_BYTE | PIPE_WAIT; + if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) + dwPipeFlags |= PIPE_REJECT_REMOTE_CLIENTS; const DWORD dwPipeBufferSize = 1024 * 1024; hRead = CreateNamedPipe(pipeName, PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED, - PIPE_TYPE_BYTE | PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS, + dwPipeFlags, 1, // only one pipe instance 0, // output buffer size dwPipeBufferSize, // input buffer size