Skip to content

Commit

Permalink
Check RequestXInformation is always 0 or 1
Browse files Browse the repository at this point in the history
  • Loading branch information
halfgaar committed May 14, 2024
1 parent c81110f commit 86a9cda
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions mqttpacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,17 +579,31 @@ ConnectData MqttPacket::parseConnectData()
result.max_outgoing_topic_aliases = std::min<uint16_t>(readTwoBytesToUInt16(), settings.maxOutgoingTopicAliasValue);
break;
case Mqtt5Properties::RequestResponseInformation:
{
if (pcounts[4]++ > 0)
throw ProtocolError("Can't specify " + propertyToString(prop) + " more than once", ReasonCodes::ProtocolError);

result.request_response_information = !!readByte();
const uint8_t x = readUint8();

if (x > 1)
throw ProtocolError(propertyToString(prop) + " must be 0 or 1", ReasonCodes::ProtocolError);

result.request_response_information = static_cast<bool>(x);
break;
}
case Mqtt5Properties::RequestProblemInformation:
{
if (pcounts[5]++ > 0)
throw ProtocolError("Can't specify " + propertyToString(prop) + " more than once", ReasonCodes::ProtocolError);

result.request_problem_information = !!readByte();
const uint8_t x = readUint8();

if (x > 1)
throw ProtocolError(propertyToString(prop) + " must be 0 or 1", ReasonCodes::ProtocolError);

result.request_problem_information = static_cast<bool>(x);
break;
}
case Mqtt5Properties::UserProperty:
readUserProperty();
break;
Expand Down

0 comments on commit 86a9cda

Please sign in to comment.