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 <Friedemann.Kleint@nokia.com>
bb10
Joerg Bornemann 2012-02-20 12:31:37 +01:00 committed by Qt by Nokia
parent 4816c42115
commit f8d6a164de
1 changed files with 4 additions and 1 deletions

View File

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