Commit Graph

1194 Commits

Author SHA1 Message Date
Marc Mutz
08f6b38ec7 QtNetwork: Use Q_NULLPTR instead of 0 in all public headers
This is in preparation of adding -Wzero-as-null-pointer-constant (or similar)
to the headers check.

Task-number: QTBUG-45291
Change-Id: I9a05d375d2d9d3ed56079ad024c89a08a290619b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2015-07-19 10:32:50 +00:00
Thiago Macieira
10c529b08d Add a way for auxiliary threads to handle events without CoreApp
Long-lived threads started by Qt itself can now receive events even if
QCoreApplication hasn't been created. This is required in all threads we
start that will handle events, unless we're sure that the thread will
exit before the global application object begins destruction.

Otherwise, those threads will have race conditions dealing with the
event delivery system trying to call the QCoreApplication::notify()
virtual while the object is being destroyed.

Change-Id: I27eaacb532114dd188c4ffff13d4ad2a4bb443e6
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2015-07-18 02:24:59 +00:00
Thiago Macieira
85ff351266 Revamp the CLOEXEC support in Qt
The pipe2/dup3/accept4 functions and SOCK_CLOEXEC are quite old nowadays
on Linux. They were introduced on Linux 2.6.28 and glibc 2.10, all from
2008. They were also picked up by uClibc in 2011 and FreeBSD as of
version 10.0. So we no longer need the runtime detection of whether the
feature is available.

Instead, if the libc has support for it, use it unconditionally and fail
at runtime if the syscall isn't implemented.

Change-Id: Ib056b47dde3341ef9a52ffff13efcc39ef8dff7d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2015-07-17 17:36:19 +00:00
Oswald Buddenhagen
68316e6584 Merge remote-tracking branch 'origin/5.4' into 5.5
Conflicts:
	doc/global/manifest-meta.qdocconf
	src/corelib/global/qnamespace.qdoc
	src/corelib/io/qstorageinfo_unix.cpp
	src/corelib/tools/qtools_p.h
	src/sql/drivers/psql/qsql_psql.cpp

Change-Id: I23a15ac84e03ad61d865e3df872b013eb0752949
2015-07-17 17:53:19 +02:00
Simon Hausmann
b2603b7665 Merge remote-tracking branch 'origin/5.5' into HEAD
Conflicts:
	src/plugins/platforms/windows/qwindowsopengltester.cpp

Change-Id: Ia7abeba9395ccf84e2fa81b91a5725a86dedb9fe
2015-07-17 16:35:42 +02:00
Marc Mutz
0b43c0a743 Mark QNetworkReplyImplPrivate::InternalNotifications as primitive
Held in QQueue, thus QList.

Change-Id: I9d13babb4c08eddbd67ede31da48c0c5f5fdbd5f
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2015-07-16 13:21:11 +00:00
Kai Koehne
0dd14aaaf1 Define friend functions of QSslEllipticCurve outside of class
Define both qHash() and operator==() outside of the class, like
it is already done for operator!=(). Defining it inside the
class limits it to argument-dependent lookup, which in turn
means that the lookup rules for operator!= and operator==
were slightly different (e.g. if one would compare variables
of a type that is implicitly convertible to QSslEllipticCurve).

As a side-effect, this also fixes a qdoc warning.

Change-Id: I40ab2f8cd2b6b5f42481dd254229a88b678f3f15
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2015-07-16 07:38:48 +00:00
Jeremy Lainé
bf36986f50 ssl: improve SecureTransport error logging
This improves SecureTransport logging consistency:

- include error code in SSL error when a native backend call fails
- use qt.network.ssl category for debug / warning messages
- do not use duplicate qWarning when error is already reported via QSslError

Change-Id: I52d457b11f0cef2cc3579305e457663b61b92f3f
Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
2015-07-15 15:32:51 +00:00
Lorn Potter
c056e63cea Make sure to report correct NetworkAccessibility
Task-number: QTBUG-46323
Change-Id: Ibdeb3280091a97d785d4314340678a63e88fb219
Reviewed-by: Markus Goetz (Woboq GmbH) <markus@woboq.com>
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
2015-07-15 01:55:12 +00:00
Marc Mutz
a545715c83 QSslSocket: remove code duplication
Since findAllLibSsl() and findAllLibCrypto() differ only in the
filter passed to QDir::entryList(), so Extract Method findAllLibs().

In the new function, cache the filters QStringList instead of re-create
it in every loop iteration.

Change-Id: I1bdd05e83fa1f9bb3f47b9b2ae5da9654ec1525b
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-07-13 22:28:17 +00:00
Jeremy Lainé
3ebbd5db7b ssl: fix SecureTransport handling of remote host disconnect
Currently when the remote server disconnects gracefully (for example upon
returning an HTTP request with Connection: close) the call to SSLRead
will return errSSLCloseGraceful which is incorrectly reported as
QAbstractSocket::SslInternalError.

This patch aligns the behavior with that of the OpenSSL backend and instead
reports QAbstractSocket::RemoteHostClosedError.

Change-Id: I8c6679280ac0c6fbd71d5f0d29b25f692eca5b24
Task-number: QTBUG-47154
Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
2015-07-13 20:15:01 +00:00
Marc Mutz
ed7f5375e1 QSslSocket: use function objects and algorithms when sorting library paths
The first change is to make libGreaterThan a function object.
This allows all compilers to inline the comparison into the
sort implementation.

The second change is to use QString::splitRef instead of
QString::split to extract the components.

The third is to extract the element comparison into a
function object and replace the rest of libGreaterThan
with a suitable call to std::lexicographical_compare,
rendering most code comments (present or missing) moot.

Change-Id: I3a761d721aa7cf5fa727dcc4ddca4b922f413899
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-07-13 10:38:25 +00:00
Markus Goetz
eae0cb09f1 Network: Fix up previous corruption patch
This is a fix-up for cff39fba10.
That patch lead to some internal state issues that lead to the QTBUG-47048
or to QNetworkReply objects erroring with "Connection Closed" when
the server closed the Keep-Alive connection.

This patch changes the QNAM socket slot connections to be DirectConnection.
We don't close the socket anymore in slots where it is anyway in a closed state
afterwards. This prevents event/stack recursions.
We also flush QSslSocket/QTcpSocket receive buffers when receiving a disconnect
so that the developer always gets the full decrypted data from the buffers.

[ChangeLog][QtNetwork] Fix HTTP issues with "Unknown Error" and "Connection Closed"
[ChangeLog][QtNetwork][Sockets] Read OS/encrypted read buffers when connection
closed by server.

Change-Id: Ib4d6a2d0d988317e3a5356f36e8dbcee4590beed
Task-number: QTBUG-47048
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-07-08 10:02:27 +00:00
Liang Qi
0aa2d318b1 Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
	src/corelib/global/qglobal.cpp
	src/corelib/global/qglobal.h
	src/corelib/global/qsysinfo.h
	src/corelib/global/qsystemdetection.h
	src/corelib/kernel/qobjectdefs.h
	src/plugins/plugins.pro
	tests/auto/widgets/itemviews/qlistview/qlistview.pro

Change-Id: Ib55aa79d707c4c1453fb9d697f6cf92211ed665c
2015-07-01 11:05:26 +02:00
Marc Mutz
65343eb283 QtNetwork: make all Q_DECLARE_SHARED types nothrow move-assignable
Change-Id: Ib29ec4b73a4cdc51074997f7d167c289cf5af7a4
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2015-06-30 10:57:50 +00:00
Nico Vertriest
a7f2af0911 Replace MAC OS X with OS X
Task-number: QTBUG-46374
Change-Id: I7bc633ab551740bd328a24b0ccae1d534af47138
Reviewed-by: Martin Smith <martin.smith@digia.com>
2015-06-30 07:33:31 +00:00
Sérgio Martins
20147fae60 Use QVector::reserve() all over the place.
Reduces internal memory fragmentation.

The search criteria was:
QVector::append(), QVector::push_back(), QVector::operator<<()
and QVector::operator+=() calls inside for, do and while loops.
Statements inside ifs and out of loops weren't considered.

Change-Id: Ie5aaf3cdfac938994e6e5dfa5f51de501ed79a0c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2015-06-29 19:31:59 +00:00
Sérgio Martins
aa09cc029f Fix inefficient container.values().first()
Saves 1 full iteration and 1 memory allocation.

Change-Id: I7e521054bd573f30dea2ec166d566ab6ac60eb4e
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2015-06-28 21:14:34 +00:00
Daniel Molkentin
027571c8c3 Also add support for linked OpenSSL without SSL v2 & v3 support
So far, this was only supported for dlopen mode. This adds symmetric
defines for the linking case.

Change-Id: I9cbfa18e04d041dde0cbd833929782cada9eb812
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-06-28 12:49:16 +00:00
Liang Qi
cb6cba2b6f Merge "Merge remote-tracking branch 'origin/5.5.0' into 5.5" into refs/staging/5.5 2015-06-28 07:46:47 +00:00
Liang Qi
4dd8a63fc1 Merge remote-tracking branch 'origin/5.5.0' into 5.5
Conflicts:
	src/plugins/platforms/cocoa/qcocoafiledialoghelper.h

Manually fixed src/testlib/qtestcase.cpp to return the right type.

Change-Id: Id1634dbe3d73fefe9431b9f5378846cb187624e4
2015-06-27 13:54:35 +02:00
Sérgio Martins
b3fc0443a0 network: Use QList::reserve(), reduces reallocations.
Change-Id: Ie0e8cbd28802826206d7e92584b5d56bb844fb09
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2015-06-27 11:48:40 +00:00
Nico Vertriest
e1b7c55a43 Doc: rearrange tables with overflow
Task-number: QTBUG-46475
Change-Id: Id599b2eb0dee0c003475c094ad61700150e37e65
Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com>
2015-06-26 11:26:24 +00:00
Ulf Hermann
b57387f6f8 Define openssl symbol resolution warning function only if necessary
Without library support we don't try to load any symbols and the
function is unused. This results in a compiler warning.

Change-Id: I82ad46a478debe48cf9a8311f5e5ec299baa1af8
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-06-22 14:21:04 +00:00
Oliver Wolff
dbddb1751e winrt: Fixed connectToHost, which is meant to be synchronous
Task-number: QTBUG-46339
Change-Id: I413fef39424a0815ef4604000f85ad37ac2b4dc2
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com>
2015-06-22 06:24:54 +00:00
Marc Mutz
886eac5213 QHttpNetworkHeaderPrivate: use QList<QByteArray>::join()
...instead of coding the loop by hand.

Change-Id: Ieaa066de1ff8552b737cf27cf0d4236efb7296eb
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2015-06-20 11:40:07 +00:00
Marc Mutz
9ab45763d7 QSpdyProtocolHandler: don't create QLists of key and value just to iterate over
Just iterate over the QMultiMap directly. Also, now that we use
iterators, the remove operation becomes amortized O(1) instead
of O(logN). The loop could be even O(N) (clean, not amortized)
if QMap had range-erase.

Change-Id: I0cf3511adc3a558e551ddd91e47dabcab376001a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2015-06-19 16:30:03 +00:00
Ulf Hermann
8558289780 QtNetwork: fix warnings when compiling with QT_NO_BEARERMANAGEMENT
Resolving d- and q-pointers in code branches where we don't use them is
wasteful and leads to compile warnings.

Change-Id: Ib5dadd247acfe48722121e0e95ffcac61e7a2e09
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2015-06-19 16:29:58 +00:00
Giuseppe D'Angelo
92cda94742 QSslSocket: move default cipher, EC and default CA APIs to QSslConfiguration
QSslConfiguration is better suited for these APIs. The ones
in QSslSocket that already have a counterpart have been deprecated.

[ChangeLog][QtNetwork][SSL/TLS Support] Most of the QSslSocket
functions to deal with ciphersuites, certification authorities
as well as elliptic curves have been deprecated in favor of the
corresponding counterparts in QSslConfiguration.

Task-number: QTBUG-46558
Change-Id: I1de03379efcbcab931c20e876e252769fe4279e0
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
Reviewed-by: Richard J. Moore <rich@kde.org>
Reviewed-by: Jani Heikkinen <jani.heikkinen@theqtcompany.com>
2015-06-11 04:18:37 +00:00
Marc Mutz
42f5f03d0a Unexport QSslPreSharedKeyAuthenticator
Exporting value classes (as opposed to just their non-inline
methods) creates subtle binary incompatibility problems.

In this case, between C++11 and C++98 builds because of the
move assignment operator.

Even though it's not a problem in practice, so far, for some
types of classes this issue ie real (QVector, say), so it's
best to avoid exporting what we don't need to export.

Change-Id: Ifca6aaedcbfa79ca35e651de7630e69c3b266fe3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2015-06-09 08:51:35 +00:00
Oswald Buddenhagen
d32f47b703 fix usage of wince scope
Fix style issues along the way.

Change-Id: Ic6a6de28e198eb0b14c198b802e78845703909b9
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
2015-06-05 10:29:10 +00:00
Simon Hausmann
e2f66f9215 Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
	src/corelib/global/qnamespace.qdoc
	src/corelib/io/qwindowspipereader.cpp
	src/corelib/io/qwindowspipereader_p.h
	src/corelib/statemachine/qstatemachine.cpp
	src/corelib/statemachine/qstatemachine_p.h
	src/plugins/platforms/xcb/qxcbconnection.h
	tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
	tests/auto/tools/qmake/tst_qmake.cpp
	tests/manual/touch/main.cpp

Change-Id: I917d694890e79ee3da7d65134b5b085e23e0dd62
2015-06-03 10:23:56 +02:00
Liang Qi
754efa57d8 Merge "Merge remote-tracking branch 'origin/5.5.0' into 5.5" into refs/staging/5.5 2015-06-02 23:39:22 +00:00
Sérgio Martins
f44a59f390 Don't assign iterator to const_iterator
It should also be possible to use QT_STRICT_ITERATORS in Qt's own code base

Change-Id: I0914db480d4d2b06e71e3a2588163efdd3ff6d27
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2015-06-02 19:41:16 +00:00
Liang Qi
fcfd31c9fd Merge remote-tracking branch 'origin/5.4' into 5.5
Conflicts:
	qmake/generators/mac/pbuilder_pbx.cpp
	src/corelib/global/qglobal.h

Change-Id: I2c0f7544bf194f2d0f59218fd583c822901487b0
2015-06-01 17:46:58 +02:00
Richard J. Moore
21ec751cdc Remove unsafe random seeding fallback path.
OpenSSL should automatically seed the random number generator, and the
current fallback code does not offer strong guarantees. It should
never actually be used, so let's remove it entirely.

Change-Id: I9a0a70345fe8df5913871bcac644623b687aea01
Reviewed-by: Peter Hartmann <peter-qt@hartmann.tk>
2015-05-29 21:34:29 +00:00
Liang Qi
0c5fbd397c Merge "Merge remote-tracking branch 'origin/5.4.2' into 5.4" into refs/staging/5.4 2015-05-29 14:17:21 +00:00
Sérgio Martins
db54498fd1 Mark two member functions const
Change-Id: I42266689ccac2d0234eb0b047d2dc949e6f59196
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2015-05-29 08:05:33 +00:00
Liang Qi
2670bdeee4 Merge remote-tracking branch 'origin/5.4.2' into 5.4
Change-Id: Ied2a227a25859163a924c7b5717492a1f974c5ca
2015-05-29 10:00:01 +02:00
Lorn Potter
386aca1ba4 Fix no bearermanagement build
As pointed out in the bug, it also fixes API use when configured
with no bearermanagement.

Task-number: QTBUG-46239
Change-Id: Ief8df85ad6acf61e8d5bb3eed54e7d6ecb84c1a0
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
2015-05-29 06:35:08 +00:00
Alex Trotsenko
ee336c2096 QAbstractSocket: remove unused member
Change-Id: I0fa3d9e1b00f38a1b04dddd09ec8c04199ad1f34
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
2015-05-26 10:14:43 +00:00
Richard J. Moore
7a4f3645f4 Avoid false positives from google by storing OpenSSL version as Unicode.
Google scan play store apps for the openssl version string which leads
to false positives since we record the version we were compiled against
even though we don't link it directly.

Task-number: QTBUG-46265
Change-Id: Iefd0e0954149c17350d49f57f9f374938124d7b8
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2015-05-25 11:25:07 +00:00
Friedemann Kleint
0c85cdb8c2 QFtp: Suppress warning about reading from closed QIODevice.
Clear bytesFromSocket when the socket is not open instead of
reading in QFtpDTP::socketConnectionClosed(), which is connected
to QTcpSocket::disconnected().

Task-number: QTBUG-46112
Change-Id: I0e5e47448f88601eb5c62fe9ba92e1a461323364
Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
2015-05-23 08:59:27 +00:00
Maurice Kalinowski
21b5298d15 WinRT: Windows 10 compilation fix
Header is required for successful compilation.

Change-Id: I401b7c6fbc594b3cd0c9a4b25afc8ff918d8bddd
Reviewed-by: Andrew Knight <andrew.knight@intopalo.com>
2015-05-22 14:27:58 +00:00
Maurice Kalinowski
7c7c815a1a MSVC2015: Compile fix
Q_DECL_NOTHROW needs to be present at the definition as well in VS2015.

Change-Id: I8a6def607aa4ae9c9fe64386a38fc1c728edd8d1
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
2015-05-22 14:17:30 +00:00
Topi Reinio
9a1283f8d3 Doc: Qt Network: List the classes on SSL Classes page
Change-Id: I32693ac3012142c04671f8278e06165396ca3242
Task-number: QTBUG-46145
Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com>
Reviewed-by: Martin Smith <martin.smith@digia.com>
2015-05-20 11:24:52 +00:00
Mikhail Lappo
3f0f707d4b Prevent bad-ptrs deref in QNetworkConfigurationManagerPrivate
Prevent application to crash with segfault in Qt bearer thread.
Corrected hardly reproduceable bug, when
QNetworkConfigurationManagerPrivate in pollEngines slot dereferenced
null and bad pointers and caused crash

Task-number: QTBUG-44407
Change-Id: I2f0b11b2d10125a21a62588d76ad824f375e4a1d
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-05-18 19:33:02 +00:00
Oliver Wolff
f65c04b37e WinRT/Winphone: Fix warnings in qtbase
Change-Id: I41725bcfeee0124b259e96f1e3a261e30f14350a
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com>
2015-05-18 08:59:55 +00:00
Allan Sandfeld Jensen
1fce111809 Merge remote-tracking branch 'origin/5.4' into merge5.5
Conflicts:
	src/corelib/global/qglobal.h
	src/corelib/io/qnoncontiguousbytedevice_p.h
	src/gui/image/qjpeghandler.cpp
	src/network/access/qhttpthreaddelegate_p.h
	tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
	tests/auto/widgets/widgets/qmenubar/BLACKLIST

Change-Id: I01de8c1c28efcedfd7953d05025f54802dc08ab3
2015-05-08 13:26:44 +02:00
Markus Goetz
00fe833189 QNAM: Fix compiler warning
Change-Id: I2ae6493e13c9b168c64c458e42ea90d4ec2d8628
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2015-05-08 09:02:51 +00:00
Volker Krause
337c279215 Make data tables const.
Moves some of them to the .rodata section, the rest at least to
.data.rel.ro[.local].

Change-Id: I85676ddf22b0c0097f3f0dce4c3dc018dc29d045
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2015-05-05 05:31:32 +00:00
Valery Kotov
a5890fbcd8 qnetworkreplyfileimpl: set attributes if file was sent
Set status code and status text if file was sent with reply.

Change-Id: Ie6acadc5c1d06538449262ffd8486e8de573b931
Task-number: QTBUG-45581
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Reviewed-by: Pasi Keränen <pasi.keranen@digia.com>
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-05-04 11:20:40 +00:00
Alex Trotsenko
737eccf1ef QNativeSocketEngine: add sendmsg(), recvmsg() wrappers on unix
These functions are useful to pass ancillary data such as extended
errors, IP options, protocol control information.

Change-Id: I27574f73a60909c7199027160ca4689511e56b72
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2015-04-28 19:35:58 +00:00
Richard J. Moore
479e84dcbd Fix exclusion of anonymous ciphers.
Qt attempted to exclude anonymous ciphers since they offer no MITM
protection, but missed export ADH ciphers and AECDH from the exclude
list.

Change-Id: Icdfa9b31643a0e9927010885c7c1d02c42460d79
Reviewed-by: Peter Hartmann <peter-qt@hartmann.tk>
2015-04-25 12:11:05 +00:00
Richard J. Moore
00f0a4119c Add the ability to prefer the cipher preferences specified by the server.
Currently the cipher preferred by the client will always be used for SSL
connections. This change makes it so that by default the ciphers
specified by the server will be used (like the Apache SSLHonorCipherOrder
option). This behavior can be disabled using a new SslOption.

[ChangeLog][QtNetwork][QSslSocket] QSslSocket will now default to using
the cipher preferences of the server socket when used as an SSL server.
This can be disabled using the QSslConfiguration.

Change-Id: I2d16d10145cf88a7412f30ef960d87024777de1c
Reviewed-by: Peter Hartmann <peter-qt@hartmann.tk>
2015-04-25 12:10:50 +00:00
Alex Trotsenko
492e710bdb QTcpSocket: add an internal c'tor
This allows further QTcpSocket inheritance in library. Using of this
c'tor is applicable to different socket types that makes them consistent
with existing TCP socket API.

Change-Id: Iafa25c365b88f52d8a3e816a296ee888ceaeb16b
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-04-23 13:37:44 +00:00
Liang Qi
aed5a71683 Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
	src/corelib/statemachine/qstatemachine.cpp
	src/corelib/statemachine/qstatemachine_p.h
	src/gui/painting/qdrawhelper.cpp
	src/plugins/platforms/xcb/qxcbnativeinterface.cpp
	src/plugins/platforms/xcb/qxcbwindow.cpp
	src/plugins/platforms/xcb/qxcbwindow.h
	src/testlib/qtestblacklist.cpp
	src/tools/qdoc/node.cpp
	src/tools/qdoc/node.h
	tests/auto/gui/painting/qcolor/tst_qcolor.cpp

Change-Id: I6c78b7b162001712d5774293f501b06b4ff32684
2015-04-22 09:25:54 +02:00
Aleix Pol
9286a8e5dd Understand file:/ url's as local
When making a QNetworkAccessManager query, don't require a network
session in case of file:/ queries, like we do when "localhost" is the
hostname or a loopback device.

Change-Id: I4faab7cf356ee53e6e13ab55b152365680af9446
Reviewed-by: Albert Astals Cid <albert.astals@canonical.com>
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-04-21 11:09:33 +00:00
Markus Goetz
cff39fba10 QNAM: Fix upload corruptions when server closes connection
This patch fixes several upload corruptions if the server closes the connection
while/before we send data into it. They happen inside multiple places in the HTTP
layer and are explained in the comments.
Corruptions are:
* The upload byte device has an in-flight signal with pending upload data, if
it gets reset (because server closes the connection) then the re-send of the
request was sometimes taking this stale in-flight pending upload data.
* Because some signals were DirectConnection and some were QueuedConnection, there
was a chance that a direct signal overtakes a queued signal. The state machine
then sent data down the socket which was buffered there (and sent later) although
it did not match the current state of the state machine when it was actually sent.
* A socket was seen as being able to have requests sent even though it was not
encrypted yet. This relates to the previous corruption where data is stored inside
the socket's buffer and then sent later.

The included auto test produces all fixed corruptions, I detected no regressions
via the other tests.
This code also adds a bit of sanity checking to protect from possible further
problems.

[ChangeLog][QtNetwork] Fix HTTP(s) upload corruption when server closes connection

Change-Id: I54c883925ec897050941498f139c4b523030432e
Reviewed-by: Peter Hartmann <peter-qt@hartmann.tk>
2015-04-20 08:00:02 +00:00
Marc Mutz
1b5f29e28a Remove <qhash.h> where it's not used
To avoid source-incompatibilites, wrap in QT_DEPRECATED_SINCE(5, 5)
in public headers.

Change-Id: I6117e8a6b11200d2f1a0a94a0e87d5c27538218e
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2015-04-20 07:41:34 +00:00
Marc Mutz
103086e379 Replace <qhash.h> with <qhashfunctions.h> where applicable
To avoid source-incompatibilites, wrap in QT_DEPRECATED_SINCE(5, 5)
in public headers.

Change-Id: Ic3398f4f330e15a3b55065858add26b90fd70e6c
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2015-04-20 07:41:27 +00:00
Liang Qi
605617b5dc Merge remote-tracking branch 'origin/5.4' into 5.5
Change-Id: I004854a25ebbf12b1fda88900162fe7878716c58
2015-04-15 09:09:24 +02:00
Alex Trotsenko
3610513450 QAbstractSocket: virtualize options setting
Some kinds of socket options can be applied only to newly created
descriptors. However, a current QAbstractSocket implementation proceeds
to actions immediately after the socket layer initialization. This
disallows a socket tuning in further inheritance.

Add a private virtual configureCreatedSocket() method that gives an
ability to set the socket options before binding or connecting.

Change-Id: I2d858a400cd46ae7fe5bf0b8900220f6121d0132
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-04-13 20:23:31 +00:00
Alex Trotsenko
1e01be433d QTcpServer: add debug messages to c'tors and d'tor
Change-Id: I257098967a18daf4f9ccd10641fe11c654cc3549
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2015-04-13 20:10:45 +00:00
Liang Qi
4973786f0d Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: I04f9f2749f68c0cb5a427b8d84e43b44bb143e4d
2015-04-08 21:24:26 +02:00
Liang Qi
20cac3d9c9 Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: If9fd98525b6b4ca07e5e006fc98bf372a73b8a21
2015-04-06 19:10:25 +02:00
Alex Trotsenko
a03c633e4f Virtualize options setting on TCP server socket
Currently, socket options setting is hardcoded in QTcpServer::listen()
function after the engine initialization and before a binding to the
address. This disallows a socket tuning in further QTcpServer inheritance.

Add a private virtual configureCreatedSocket() method that gives an
ability to set the socket options before listening.

Change-Id: Ice9b477e64f21daee96c0ec6d27a8408f9e1aa93
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2015-04-05 15:00:01 +00:00
Daniel Molkentin
c1a67e7dc3 Windows: Do not crash if SSL context is gone after root cert lookup
On Windows, we perform an extra certificate lookup for root CAs that
are not in Windows' (minimal) root store. This check can take up to
15 seconds. The SSL context can already be gone once we return. Hence
we now check for a non-null SSL context on Windows before proceeding.

Change-Id: I1951569d9b17da33fa604f7c9d8b33255acf200d
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-04-01 07:33:20 +00:00
Albert Astals Cid
1458d1b31d Use allConfigurations instead of onlineConfigurations in isOnline()
We need it because otherwise code like
  QNetworkConfigurationManager ncm;
  qDebug() << "ONLINE" << ncm->isOnline();
may give the wrong value because the queued signals that have been just connected a few lines above
may not have been processed yet

Change-Id: I959db75ed17497ab91eeba2669ee2c8947244f00
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
2015-04-01 07:22:10 +00:00
Liang Qi
0e6ee136c9 Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
	src/testlib/qtestblacklist.cpp
	src/widgets/accessible/qaccessiblewidgets.cpp

Change-Id: If032adb9296428f62384ed835dbf41ee7a0b886c
2015-04-01 09:10:26 +02:00
Alex Trotsenko
633b950bd4 QSslSocket: try to send all data on close()
Takes care about unencrypted data in the socket writeBuffer when
close() flushes the output.

Change-Id: I301f41ea709817e215ee4246a3951e3182d94fbd
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-04-01 06:04:07 +00:00
Ludger Krämer
9ea8082658 fix high memory usage on large download
previously the whole response was cached in a NSMutableData which leads
to high memory usage on large responses (e.g. downloading a large file).
With this patch only the part of the answer that has not yet been read
by the caller is cached.

Task-number: QTBUG-41356
Change-Id: Ic2fe822552620d8835a2c81f8c76dd170fe6ec97
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
2015-03-31 06:24:07 +00:00
Alex Trotsenko
add3c14a28 QAbstractSocket: fix some 64-bit issues in debug code
Change-Id: I78b307b2841353f84b033a815035436ec3eef3b0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2015-04-07 06:42:42 +00:00
Peng Wu
d890bc7877 winrt: Fix UDP socket writeDatagram
Remove DataWriter usage and share the write implementation with the rest of the class.

Change-Id: I87734d1bf65ad2e602279317c625885d6f829b6a
Task-number: QTBUG-44051
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
2015-03-27 13:18:27 +00:00
Timur Pocheptsov
a72b3ab73c QSSLSocketPrivateBackend::transmit - fix Secure Transport version
New SSL backend fails to read data most of the time.

This patch:

1. Removes direct call to _q_SSLRead - it was never executed (intentionally)
   and is completely  horrible and redundant.
2. Changes the reading loop - read not while we have bytesAvailable, but
   until we have errSSLWouldBlock.

Change-Id: I3fc5ff94ded76fcc1748d4979f7af85740b4b6aa
Task-number: QTBUG-45290
Reviewed-by: Richard J. Moore <rich@kde.org>
Reviewed-by: Jeremy Lainé <jeremy.laine@m4x.org>
Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com>
2015-04-01 15:36:45 +00:00
Liang Qi
ce9519593a Merge remote-tracking branch 'origin/5.4' into 5.5
Conflicts:
	mkspecs/android-g++/qmake.conf
	qmake/generators/unix/unixmake2.cpp
	src/gui/image/qimage_conversions.cpp

Change-Id: Ib76264b8c2d29a0228438ec02bd97d4b97545be0
2015-03-31 10:03:31 +02:00
Simon Hausmann
198606f6db Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
	src/plugins/platforms/xcb/qxcbnativeinterface.cpp
	src/plugins/platforms/xcb/qxcbnativeinterface.h

Change-Id: I31b38ba439b9341d51a01c0fd54bea33f7410076
2015-03-16 10:31:07 +01:00
Thiago Macieira
d1cd75e81a QNativeSocketEngine: merge the get/setsockopt level constants
No point in having them separate, as that's a recipe for mistakes.

Change-Id: Iee8cbc07c4434ce9b560ffff13ca4132cd1879ed
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-15 19:00:11 +00:00
Allan Sandfeld Jensen
32d1803d60 Please valgrind by not accessing uninitialized memory
Fix access or uninitialized memory. It is safe in this case, but causes
valgrind's memcheck to complain unnecessarily.

Change-Id: I01ad09d282b07f7099ad6bed85f4327b3c7c677f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2015-03-14 09:54:24 +00:00
Thiago Macieira
f5edf2b6fb IPv6 scope IDs are unsigned
We need to make sure that a large scope ID saved in a QString does get
converted properly back to an integer.

Change-Id: Iee8cbc07c4434ce9b560ffff13c9bd0e9008bd9c
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-14 01:15:21 +00:00
Thiago Macieira
bc59424ed4 QNativeSocketEngine: merge duplicated code for sin6_scope_id
Let's make sure we don't accidentally have it wrong in one of the three
versions.

Change-Id: Iee8cbc07c4434ce9b560ffff13c9bcf75ba66a66
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-14 01:15:18 +00:00
Allan Sandfeld Jensen
5ce218e142 Fix warning and improve the signature of parseRedirectResponse
Fixes unnecessary indirect return value and deprecated construction
of QString from QByteArray.

Change-Id: I4b654348285923ac1df39fc03784175ad6acb674
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-13 10:24:47 +00:00
Albert Astals Cid
afaf8a1650 Remove #ifndef QT_NO_HTTP that does nothing
Change-Id: I9d6771e9da64e59f8a038dd3b506e6293fcb62c0
Reviewed-by: Jan Kundrát <jkt@kde.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-13 08:40:53 +00:00
Thiago Macieira
f1a365dbd8 Make sure we also treat QAbstractSocket::AnyIPProtocol as IPv6
The native socket engine sets the socketProtocol to that when it means
it's using IPv6 with v4 compatibility on (v6only = false).

We mustn't have faced problems so far because the multicast tests set
don't test v6only = false.

Change-Id: Iee8cbc07c4434ce9b560ffff13ca0aff60673940
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-12 16:44:27 +00:00
Timur Pocheptsov
53207e820c Secure Transport - handle errSSLBadCert in server mode
Suddenly :(( With Security Framework v 7.0 dated by 17/02 SSLHandshake
works differently when our server socket is requesting a client side authentication
and client provides no certificate. Despite of kTryAuthenticate (this means,
auth. _can_ fail) server receives an error from SSLHandshake too early.
We have to handle this in startHandshake (when serveMode && canIgnore).

Change-Id: Ie55540078e2944e80cf2f4ade8b000acf29d6ca2
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-12 13:32:23 +00:00
Alex Trotsenko
9dd0bb851b Make QRingBuffer a 64-bit safe
According to I/O API, QIODevice and its inherited classes should be
able to process a full 64-bit offsets and lengths. This requires
64-bit parameters in operations with internal buffers. Rework
QRingBuffer to avoid implicit truncation of numbers and fix some
64-bit issues in code.

Change-Id: Iadd6fd5fefd2d64e6c084e2feebb4dc2d6df66de
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2015-03-12 05:33:20 +00:00
Thiago Macieira
e5e1e056e8 Silence MSVC warning about 64-bit conversion (loss of data)
One of the reasons why we use "int" everywhere: to avoid this annoyance
about different types and having to explicitly cast to silence the
compiler.

qsslsocket_openssl.cpp(690) : warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data

Change-Id: Ia0aac2f09e9245339951ffff13c8bdad334ce108
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-12 02:47:47 +00:00
Thiago Macieira
aa246e487c QHostAddress: add IPv6 address overloads that take const data
It has been a historical mistake that there wasn't a const overload.

Change-Id: Ia0aac2f09e9245339951ffff13c8d8b70f206a99
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-12 02:47:05 +00:00
Thiago Macieira
08e45154fb QtNetwork: Fix const correctness in old style casts
Found with GCC's -Wcast-qual.

Change-Id: Ia0aac2f09e9245339951ffff13c946859c282001
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-12 02:46:59 +00:00
Daniel Teske
ed0c0070f9 Introduce qt_subtract_from_timeout to reduce code duplication.
The same qt_timeout_value function was copied 5 times in qtbase's code,
so provide a common implementation in QIoDevice that can be used by
everyone.

This commit also corrects the remaining time calculation in
QProcess::waitForBytesWritten and QProcess::waitForFinished by using
this new function.

For QProcess::waitForFinished, if the process started within almost exactly
the timeout time passed to waitForFinished, msecs - stopWatch.elapsed() would
be -1, which is a special value.

Change-Id: I7b76ee6bae695eafdd02e3db03e2ff1e23a7f40c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2015-03-09 17:11:54 +00:00
Frederik Gladhorn
4dc459837b Merge "Merge remote-tracking branch 'origin/5.5' into dev" into refs/staging/dev 2015-03-09 11:19:22 +00:00
Frederik Gladhorn
6cef72d0b4 Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: I9d10911c51700965f2cf0e3173b88fd9116bd3ee
2015-03-09 10:23:15 +01:00
Mandeep Sandhu
d815de8c26 QNetworkAccessManager: Support HTTP redirection
This commit adds support for following HTTP redirect responses on a per
request basis.

This behavior is disabled by default. It can be switched on by
setting the QNetworkRequest::FollowRedirectAttribute to true.

2 new error codes have been added to QNetworkReply:

* TooManyRedirectsError: Set when the number of redirects exceed a
given value set by the user (defaults to 50 if not set)

* UnsecureRedirectError: Set when we are redirecting from a 'https'
to 'http' protocol.

Test cases for the following scenarios:
* Single HTTP redirect using local test server
* Changing max-redirects
* Testing all redirect related error scenarios

The next commit will extend this feature at a QNAM level.

Task-number: QTBUG-8232
Change-Id: If9e28ad12bad08bcdc5bc511b1cd59dc9d8150f0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
2015-03-09 08:32:14 +00:00
Thiago Macieira
1cd8d67d5f Fix NTLM possible data corruption
A mistake in const correctness resulted in the incoming QByteArray
getting modified when it shouldn't. I have no ldea if this could result
in user-visible effects.

Change-Id: Ia0aac2f09e9245339951ffff13c8d8c6b4f909bd
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-07 21:32:41 +00:00
Thiago Macieira
775d04f97e Add a QHostAddress::toIPv4Address overload taking a bool *ok
This allows one to check whether the conversion is successful without
checking for the return result, as the value of 0 represents the valid
IPv4 address 0.0.0.0.

Change-Id: I637fe55583f2255c85b0d955e5886b61494e0c7c
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-06 07:53:59 +00:00
Thiago Macieira
ab8d36d6f3 QHostAddress: Convert AnyIPv4 to AnyIPv6 instead of ::ffff:0.0.0.0
Unlike localhost (127.0.0.1), there's really no point in using
::ffff:0.0.0.0, since you shouldn't be sending packets to it. Linux
transforms 0.0.0.0 to localhost, but that's non-standard and won't work
on other OSs, so it's still a bad idea.

Change-Id: I5982b21bf953e11e04fc19893f94be90ed29089b
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-06 07:53:55 +00:00
Thiago Macieira
c64d27a9f7 QHostAddress: Revert auto-converting of IPv6 v4-mapped addresses to IPv4
In 85136496bc, Shane made QHostAddress
automatically convert any IPv6 address that was v4-mapped to IPv4 in
QHostAddress. While that is an interesting trick, it prevents us from
being specific about what we want. On some OS (like FreeBSD and OS X),
the distinction is relevant, so keep it.

Moreover, it was inconsistent: it might fail depending on how the
QHostAddress was constructed and the order of comparison.

[ChangeLog][Important Behavior Changes] QHostAddress will no longer
convert IPv6 addresses of type "v4-mapped" to IPv4. To perform this
conversion manually, construct another QHostAddress with the result of
toIPv4Address().

Change-Id: I06afbc7018539804bb3044ef1fe6a49ac7a5f240
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-06 07:53:50 +00:00
Florian Bruhin
c4c895d2dd Remove unneeded check in QNetworkReplyImpl::abort.
QNetworkReplyImpl::abort immediately returns at the beginning of the function
when the state is already finished, and the state does not get changed by the
code in between - so this condition will always be true.

Change-Id: Ia98df7cbecf471c7236b5e17caddd1301b647d2b
Reviewed-by: Peter Hartmann <peter-qt@hartmann.tk>
2015-03-05 10:57:32 +00:00
Thiago Macieira
126d489f7f Adjust the socket address family before bind()/connect()/sendto()
If our socket is already of a given type (probably due to a previous
call to bind()), then constrain the incoming target address to be of the
same family. On some OSs, trying to send or connect to an IPv4 address
from an IPv6 socket will fail with EINVAL, even if the socket is not in
"v6only" mode.

bind() can't be called after already being bound, but the function can
still be called on a socket created by the user and passed on with
setSocketDescriptor().

Change-Id: I209a1f8d0c782c6b6de2b39ea4cfad74d63f3293
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-04 23:58:11 +00:00
Thiago Macieira
9fb68a90af Fix bind+connect in both TCP and UDP
This has been known to be broken for a while. Now it works: you can bind
and you'll retain the port (and the file descriptor) for the connect
call. Incidentally, in fixing the binding for more than one IP for the
hostname (with event loop), this commit fixes the setSocketDescriptor
XFAIL.

[ChangeLog][QtNetwork] Fixed a bug that caused both QTcpSocket and
QUdpSocket to close the socket and lose any bound ports before
connecting. Now bind()/setSocketDescriptor() followed by connect() will
retain the original file descriptor.

Task-number: QTBUG-26538
Change-Id: I691caed7e8fd16a9cf687b5995afbf3006bf453a
Reviewed-by: Richard J. Moore <rich@kde.org>
2015-03-04 23:58:03 +00:00