Commit c3961e7f0f1c8a6e7b1e7ec6be42dc4d59ef8792
1 parent
d05d2975
Check valid header bytes in subscribe
Showing
1 changed file
with
5 additions
and
0 deletions
mqttpacket.cpp
| ... | ... | @@ -327,6 +327,11 @@ void MqttPacket::handleDisconnect() |
| 327 | 327 | |
| 328 | 328 | void MqttPacket::handleSubscribe() |
| 329 | 329 | { |
| 330 | + const char firstByteFirstNibble = (first_byte & 0x0F); | |
| 331 | + | |
| 332 | + if (firstByteFirstNibble != 2) | |
| 333 | + throw ProtocolError("First LSB of first byte is wrong value for subscribe packet."); | |
| 334 | + | |
| 330 | 335 | uint16_t packet_id = readTwoBytesToUInt16(); |
| 331 | 336 | |
| 332 | 337 | std::list<char> subs_reponse_codes; | ... | ... |