summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2020-02-27 05:23:39 +0300
committerKonstantin Ritt <ritt.ks@gmail.com>2020-03-31 12:50:36 +0300
commit37ffdcb55f9567e09bee3f230c07d02d1b7ddfa7 (patch)
treea83bfd82c4e57a6b03f8bd976cebbe8b3a7f96b1
parentf8ecf4d56a3a955c7f11db1fa32dada9dfcfb8e6 (diff)
Fix handling of incoming MQTT 5 AUTH Control packet
QMqttControlPacket::AUTH wasn't handled in the switch, causing connection close with ProtocolViolation error. Change-Id: I6a9f44b66a8c8e9a6524bf98513428c5dc610a5b Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
-rw-r--r--src/mqtt/qmqttconnection.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mqtt/qmqttconnection.cpp b/src/mqtt/qmqttconnection.cpp
index b8ab752..acae99f 100644
--- a/src/mqtt/qmqttconnection.cpp
+++ b/src/mqtt/qmqttconnection.cpp
@@ -1809,6 +1809,22 @@ bool QMqttConnection::processDataHelper()
m_missingData = remaining;
break;
}
+ case QMqttControlPacket::AUTH:
+ if (m_clientPrivate->m_protocolVersion != QMqttClient::MQTT_5_0) {
+ qCDebug(lcMqttConnection) << "Received unknown command.";
+ closeConnection(QMqttClient::ProtocolViolation);
+ return false;
+ }
+ qCDebug(lcMqttConnectionVerbose) << "Received AUTH";
+ if ((m_currentPacket & 0x0F) != 0) {
+ qCDebug(lcMqttConnection) << "Malformed fixed header for AUTH.";
+ closeConnection(QMqttClient::ProtocolViolation);
+ return false;
+ }
+ m_missingData = readVariableByteInteger();
+ if (m_missingData == -1)
+ return false; // Connection closed inside readVariableByteInteger
+ break;
default:
qCDebug(lcMqttConnection) << "Received unknown command.";
closeConnection(QMqttClient::ProtocolViolation);