Avoid use of v4-mapped QHostAddress::AnyIPv4 local address on Windows
Some Windows kernels return a v4-mapped QHostAddress::AnyIPv4 as a 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. To allow handling of the local addresses properly, replace it with QHostAddress::Any. Already tested by tst_qudpsocket. Task-number: QTBUG-52714 Change-Id: Icb7cb75f48cd7ec9b0a9dfaf861ffe0d3093e20d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
728a1b4f29
commit
4ef269963b
|
|
@ -573,6 +573,19 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
|
|||
}
|
||||
}
|
||||
|
||||
// Some Windows kernels return a v4-mapped QHostAddress::AnyIPv4 as a
|
||||
// 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) {
|
||||
bool ok = false;
|
||||
const quint32 localIPv4 = localAddress.toIPv4Address(&ok);
|
||||
if (ok && localIPv4 == INADDR_ANY) {
|
||||
socketProtocol = QAbstractSocket::AnyIPProtocol;
|
||||
localAddress = QHostAddress::Any;
|
||||
}
|
||||
}
|
||||
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
if (::getpeername(socketDescriptor, &sa.a, &sockAddrSize) == 0) {
|
||||
qt_socket_getPortAndAddress(socketDescriptor, &sa, &peerPort, &peerAddress);
|
||||
|
|
|
|||
Loading…
Reference in New Issue