From 91c1b5490e63705b5418ffbae539ff70dbdfe334 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Fri, 28 Apr 2017 18:36:04 +0300 Subject: QWindowsPipeReader: fix possible invalid invocation of ReadFileEx() If the user calls QLocalSocket::setReadBufferSize() with a value less than the current size of the pipe buffer, startAsyncRead() would call ReadFileEx() with invalid parameters: ReadFileEx(handle, nullptr, some_big_value, ...); Change-Id: I3d153e3ec34f8038dc001c1c896aeceb666a8979 Reviewed-by: Thiago Macieira --- tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index a74a056d91..60ee4eb471 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -625,6 +625,18 @@ void tst_QLocalSocket::readBufferOverflow() QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); // no more bytes available QCOMPARE(client.bytesAvailable(), 0); + +#ifdef Q_OS_WIN + // Test overflow caused by an asynchronous pipe operation. + client.setReadBufferSize(1); + serverSocket->write(buffer, 2); + + QVERIFY(client.waitForReadyRead()); + // socket disconnects, if there any error on pipe + QCOMPARE(client.state(), QLocalSocket::ConnectedState); + QCOMPARE(client.bytesAvailable(), qint64(2)); + QCOMPARE(client.read(buffer, 2), qint64(2)); +#endif } static qint64 writeCommand(const QVariant &command, QIODevice *device, int commandCounter) -- cgit v1.2.3