summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorKalle Viironen <kalle.viironen@digia.com>2012-01-26 10:33:47 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-03-19 14:16:36 (GMT)
commit68b1d5c17aa38d5921bdade2b0e0cb67c6c90513 (patch)
treeb759f8421f23876b85c97536bf5277c75593e868 /src/network
parentc0b782e8c516245bd534542f3682e7e25a33c414 (diff)
downloadQt-68b1d5c17aa38d5921bdade2b0e0cb67c6c90513.zip
Qt-68b1d5c17aa38d5921bdade2b0e0cb67c6c90513.tar.gz
Qt-68b1d5c17aa38d5921bdade2b0e0cb67c6c90513.tar.bz2
Fix bug in qsslsocket peek()
Calling peek() for qsslsocket caused socket data to be copied into qiodevices buffer and therefore make it unaccessible in qsslsocket. Task-number: QTBUG-18498 Change-Id: Ie27a90a468be8158bd8afcd259dbb34483623c36 Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/ssl/qsslsocket.cpp35
-rw-r--r--src/network/ssl/qsslsocket_p.h3
2 files changed, 38 insertions, 0 deletions
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index f89b9b3..7fc36c8 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -2246,6 +2246,41 @@ void QSslSocketPrivate::_q_flushReadBuffer()
/*!
\internal
*/
+qint64 QSslSocketPrivate::peek(char *data, qint64 maxSize)
+{
+ if (mode == QSslSocket::UnencryptedMode && !autoStartHandshake) {
+ if (plainSocket)
+ return plainSocket->peek(data, maxSize);
+ else
+ return -1;
+ } else {
+ QByteArray tmp;
+ tmp = readBuffer.peek(maxSize);
+ memcpy(data, tmp.data(), tmp.length());
+ return tmp.length();
+ }
+}
+
+/*!
+ \internal
+*/
+QByteArray QSslSocketPrivate::peek(qint64 maxSize)
+{
+ if (mode == QSslSocket::UnencryptedMode && !autoStartHandshake) {
+ if (plainSocket)
+ return plainSocket->peek(maxSize);
+ else
+ return QByteArray();
+ } else {
+ QByteArray tmp;
+ tmp = readBuffer.peek(maxSize);
+ return tmp;
+ }
+}
+
+/*!
+ \internal
+*/
QList<QByteArray> QSslSocketPrivate::unixRootCertDirectories()
{
return QList<QByteArray>() << "/etc/ssl/certs/" // (K)ubuntu, OpenSUSE, Mandriva, MeeGo ...
diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h
index 606352b..58515c9 100644
--- a/src/network/ssl/qsslsocket_p.h
+++ b/src/network/ssl/qsslsocket_p.h
@@ -159,6 +159,9 @@ public:
void _q_flushWriteBuffer();
void _q_flushReadBuffer();
+ virtual qint64 peek(char *data, qint64 maxSize);
+ virtual QByteArray peek(qint64 maxSize);
+
// Platform specific functions
virtual void startClientEncryption() = 0;
virtual void startServerEncryption() = 0;