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>
bb10
Thiago Macieira 2020-02-07 12:21:33 -08:00
parent 2310d9dc65
commit 5ff37f13ee
3 changed files with 3 additions and 9 deletions

View File

@ -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) {

View File

@ -1,10 +1,3 @@
[bind]
windows-10 msvc-2015
windows-7sp1
[bind:[::]]
windows
[bind:[::]:randomport]
windows
[timeoutConnect:ip]
windows
# QTBUG-66247

View File

@ -585,7 +585,7 @@ void tst_QTcpSocket::bind()
if (successExpected) {
bool randomPort = port == -1;
int attemptsLeft = 5; // only used with randomPort
int attemptsLeft = 5; // only used with randomPort or Windows
do {
if (randomPort) {
// try to get a random port number