summaryrefslogtreecommitdiffstats
path: root/src/network/socket
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2020-02-07 12:21:33 -0800
committerThiago Macieira <thiago.macieira@intel.com>2020-02-13 15:11:11 -0800
commit5ff37f13ee577c006f0b99307d0afa1cf991db08 (patch)
tree2c4a6843cdc6cc61a353a73defbbaf44f86abea5 /src/network/socket
parent2310d9dc65b4d69e04e4aaa4f393722b7fff653d (diff)
QTcpSocket::bind: fix issue found by BLACKLIST
The comment in QNativeSocketEnginePrivate::fetchConnectionParameters() talked about IPv6 v4-mapped addresses. However, toIPv4Address also converts the unspecified address (::), which resulted in QAbstractSocket saying that it had bound to QHostAddress::Any instead of QHostAddress::AnyV6 Change-Id: I572733186b73423b89e5fffd15f138579c5c0c50 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network/socket')
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index 9edabd7822..78be0a7e0f 100644
--- a/src/network/socket/qnativesocketengine_win.cpp
+++ b/src/network/socket/qnativesocketengine_win.cpp
@@ -588,7 +588,8 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
// local address of the socket which bound on both IPv4 and IPv6 interfaces.
// This address does not match to any special address and should not be used
// to send the data. So, replace it with QHostAddress::Any.
- if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ const uchar ipv6MappedNet[] = {0,0,0,0, 0,0,0,0, 0,0,0xff,0xff, 0,0,0,0};
+ if (localAddress.isInSubnet(QHostAddress(ipv6MappedNet), 128 - 32)) {
bool ok = false;
const quint32 localIPv4 = localAddress.toIPv4Address(&ok);
if (ok && localIPv4 == INADDR_ANY) {