summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaurice Kalinowski <maurice.kalinowski@qt.io>2018-07-30 12:11:29 +0200
committerMaurice Kalinowski <maurice.kalinowski@qt.io>2018-07-31 07:37:03 +0000
commit57f386f26b82b3b339934b4cc8affaf6380158b2 (patch)
treece82bab0ae573f410c0d43f669c50b649eab7e83 /src
parent001c3e7edc5c3253316e31acb30b8cff5b3387bf (diff)
MQTT5: Fix puback parsing
PUBACK may contain properties, but does not have to. Even more it does not need to indicate absence of properties by adding a zero-length byte. This got revealed while updating to the latest test broker. Change-Id: Id1d8f9848d98ddf7e93bbafb54d91024e4f4f020 Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io> Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/mqtt/qmqttconnection.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/mqtt/qmqttconnection.cpp b/src/mqtt/qmqttconnection.cpp
index 232d0ca..45515a6 100644
--- a/src/mqtt/qmqttconnection.cpp
+++ b/src/mqtt/qmqttconnection.cpp
@@ -1384,14 +1384,16 @@ void QMqttConnection::finalize_pubAckRecComp()
const quint8 reasonCode = readBufferTyped<quint8>();
m_missingData--;
Q_UNUSED(reasonCode); // ### TODO: Do something with it, currently silences compiler
- // Property Length (Variable Int)
- qint32 byteCount = 0;
- const qint32 propertyLength = readVariableByteInteger(&byteCount);
- m_missingData -= byteCount;
- // ### TODO: Publish ACK/REC/COMP property handling
- if (propertyLength > 0) {
- readBuffer(quint64(propertyLength));
- m_missingData -= propertyLength;
+ if (m_missingData > 0) {
+ // Property Length (Variable Int)
+ qint32 byteCount = 0;
+ const qint32 propertyLength = readVariableByteInteger(&byteCount);
+ m_missingData -= byteCount;
+ // ### TODO: Publish ACK/REC/COMP property handling
+ if (propertyLength > 0) {
+ readBuffer(quint64(propertyLength));
+ m_missingData -= propertyLength;
+ }
}
}
if ((m_currentPacket & 0xF0) == QMqttControlPacket::PUBCOMP) {