1
0
mirror of https://github.com/qt/qtmqtt.git synced 2026-10-25 16:16:26 +00:00

PINGRESP from the network should not push the counter below zero

- finalize_pingresp() lowers m_pingTimeout every time, with no lower
limit. A broker can send a pile of unasked-for replies to push the
counter deep below zero, and then the client can spend some unexpected
amount of time to reach back the number that means:
"the broker has stopped answering, drop the link.”
- The fix prohibits pushing the counter below zero.

Task-number: QTBUG-149662
Pick-to: 6.8
Change-Id: I7b25e8ac3f83fa262a19010df9a91b2ee1c006fd
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 33538c5143)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 88430cff7a)
This commit is contained in:
Tatiana Borisova 2026-08-31 17:12:30 +02:00 committed by Qt Cherry-pick Bot
parent e5185f5eab
commit 5b5aa01569

View File

@ -1911,7 +1911,10 @@ void QMqttConnection::finalize_pingresp()
closeConnection(QMqttClient::ProtocolViolation);
return;
}
m_pingTimeout--;
// Unexpected PINGRESP from the network should not push the counter below zero.
if (m_pingTimeout > 0)
m_pingTimeout--;
emit m_clientPrivate->m_client->pingResponseReceived();
}