summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2020-04-20 12:43:40 +0300
committerKonstantin Ritt <ritt.ks@gmail.com>2020-05-06 14:44:13 +0300
commitd2806f040c926e500ba19da34b58fd31cdc63394 (patch)
tree10d54411ba5b2edfde302915c0df70bfbfa106fc
parent5c5664c77662d6b6e21c8542d63951974fcf138d (diff)
Do not ignore MQTT 5 protocol violations in some more cases
The exceptional texts in 3.4.2.1, 3.5.2.1, 3.6.2.1, 3.7.2.1, 3.14.2.1 and 3.15.2.1 propose a micro optimization: > The Reason Code and Property Length can be omitted > if the Reason Code is 0x00 (Success) and there are no Properties. which our current implementation treats like if it were "The Property Length can be omitted if the Reason Code is 0x00". In theory, this optimization could apply to CONNACK as well, as there is a reason code and no payload, but that's not stated anywhere in the spec and should not be assumed. Change-Id: Ifaf9a3c45876661b8f7a4d688600f53b46288752 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
-rw-r--r--src/mqtt/qmqttconnection.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/mqtt/qmqttconnection.cpp b/src/mqtt/qmqttconnection.cpp
index d17cef8..d55b0cd 100644
--- a/src/mqtt/qmqttconnection.cpp
+++ b/src/mqtt/qmqttconnection.cpp
@@ -1385,18 +1385,15 @@ void QMqttConnection::finalize_auth()
{
qCDebug(lcMqttConnectionVerbose) << "Finalize AUTH";
- const quint8 authReason = readBufferTyped<quint8>(&m_missingData);
-
+ quint8 authReason = 0;
QMqttAuthenticationProperties authProperties;
// 3.15.2.1 - The Reason Code and Property Length can be omitted if the Reason Code
// is 0x00 (Success) and there are no Properties. In this case the AUTH has a
// Remaining Length of 0.
- if (m_missingData == 0 && authReason != 0) {
- qCDebug(lcMqttConnection) << "Received non success AUTH without properties.";
- closeConnection(QMqttClient::ProtocolViolation);
- return;
- } else if (m_missingData > 0)
+ if (m_missingData > 0) {
+ authReason = readBufferTyped<quint8>(&m_missingData);
readAuthProperties(authProperties);
+ }
// 3.15.2.1
switch (QMqtt::ReasonCode(authReason)) {
@@ -1692,8 +1689,7 @@ void QMqttConnection::finalize_pubAckRecRelComp()
}
}
- if (m_missingData > 0)
- readMessageStatusProperties(properties);
+ readMessageStatusProperties(properties);
}
if ((m_currentPacket & 0xF0) == QMqttControlPacket::PUBREL) {