From ca49f133f0a0bcf62caf858a81325b0a9bf668c6 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Sat, 30 Sep 2017 16:11:20 +0300 Subject: [PATCH] QSslSocket: implement skip() overload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As QAbstractSocket does not handle most cases for this socket type, we should override skip() in QSslSocketPrivate implementation. In unencrypted mode, QSslSocket should forward skipping to the plain socket. If a connection is secure, we just need to check the connection state. Change-Id: I56602c6427b8617e8a9f453809a30fb2914ad798 Reviewed-by: Edward Welbourne Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Timur Pocheptsov --- src/network/ssl/qsslsocket.cpp | 14 ++++++++++++++ src/network/ssl/qsslsocket_p.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 5c9ebac283a..84c814cca41 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -2644,6 +2644,20 @@ QByteArray QSslSocketPrivate::peek(qint64 maxSize) } } +/*! + \internal +*/ +qint64 QSslSocketPrivate::skip(qint64 maxSize) +{ + if (mode == QSslSocket::UnencryptedMode && !autoStartHandshake) + return plainSocket->skip(maxSize); + + // In encrypted mode, the SSL backend writes decrypted data directly into the + // QIODevice's read buffer. As this buffer is always emptied by the caller, + // we need to wait for more incoming data. + return (state == QAbstractSocket::ConnectedState) ? Q_INT64_C(0) : Q_INT64_C(-1); +} + /*! \internal */ diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h index 9d45d016951..ced861805b3 100644 --- a/src/network/ssl/qsslsocket_p.h +++ b/src/network/ssl/qsslsocket_p.h @@ -192,6 +192,7 @@ public: virtual qint64 peek(char *data, qint64 maxSize) override; virtual QByteArray peek(qint64 maxSize) override; + qint64 skip(qint64 maxSize) override; bool flush() override; // Platform specific functions