From aa494d826ace02ffff5f29ae20b7738630913777 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 12 Nov 2017 09:58:25 -0800 Subject: [PATCH] QNetworkInterface/Win: fix MTU of Windows loopback interfaces We document that -1 is not a valid value. The Windows structure's type is unsigned, so the value is actually ULONG_MAX. Change-Id: Ic632b4163d784b83951cfffd14f668645c4da3a9 Reviewed-by: Timur Pocheptsov Reviewed-by: Edward Welbourne --- src/network/kernel/qnetworkinterface_win.cpp | 2 +- .../network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp index 857e40215c..150553f673 100644 --- a/src/network/kernel/qnetworkinterface_win.cpp +++ b/src/network/kernel/qnetworkinterface_win.cpp @@ -151,7 +151,7 @@ static QList interfaceListing() else if (ptr->IfIndex != 0) iface->index = ptr->IfIndex; - iface->mtu = ptr->Mtu; + iface->mtu = qMin(ptr->Mtu, INT_MAX); iface->flags = QNetworkInterface::CanBroadcast; if (ptr->OperStatus == IfOperStatusUp) iface->flags |= QNetworkInterface::IsUp | QNetworkInterface::IsRunning; diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp index ae5082fecb..93dd73d64a 100644 --- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp +++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp @@ -184,6 +184,8 @@ void tst_QNetworkInterface::consistencyCheck() if (iface.index()) interfaceIndexes << iface.index(); + QVERIFY(iface.maxTransmissionUnit() >= 0); + const QList addresses = iface.addressEntries(); for (auto entry : addresses) { QVERIFY(entry.ip().protocol() != QAbstractSocket::UnknownNetworkLayerProtocol);