From c3961e7f0f1c8a6e7b1e7ec6be42dc4d59ef8792 Mon Sep 17 00:00:00 2001 From: Wiebe Cazemier Date: Thu, 11 Mar 2021 22:31:00 +0100 Subject: [PATCH] Check valid header bytes in subscribe --- mqttpacket.cpp | 5 +++++ 1 file changed, 5 insertions(+), 0 deletions(-) diff --git a/mqttpacket.cpp b/mqttpacket.cpp index f529ef3..acde794 100644 --- a/mqttpacket.cpp +++ b/mqttpacket.cpp @@ -327,6 +327,11 @@ void MqttPacket::handleDisconnect() void MqttPacket::handleSubscribe() { + const char firstByteFirstNibble = (first_byte & 0x0F); + + if (firstByteFirstNibble != 2) + throw ProtocolError("First LSB of first byte is wrong value for subscribe packet."); + uint16_t packet_id = readTwoBytesToUInt16(); std::list subs_reponse_codes; -- libgit2 0.21.4