Skip to content

Commit b56daed

Browse files
committed
Detect invalid reason codes in PUBREC
1 parent a88a01a commit b56daed

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

mqttpacket.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,6 +2292,27 @@ PubRecData MqttPacket::parsePubRecData()
22922292
if (!atEnd())
22932293
{
22942294
result.reasonCode = static_cast<ReasonCodes>(readUint8());
2295+
2296+
if (result.reasonCode > ReasonCodes::Success)
2297+
{
2298+
switch(result.reasonCode)
2299+
{
2300+
case ReasonCodes::Success:
2301+
case ReasonCodes::NoMatchingSubscribers:
2302+
case ReasonCodes::UnspecifiedError:
2303+
case ReasonCodes::ImplementationSpecificError:
2304+
case ReasonCodes::NotAuthorized:
2305+
case ReasonCodes::TopicNameInvalid:
2306+
case ReasonCodes::PacketIdentifierInUse:
2307+
case ReasonCodes::QuotaExceeded:
2308+
case ReasonCodes::PayloadFormatInvalid:
2309+
{
2310+
break;
2311+
}
2312+
default:
2313+
throw ProtocolError("Invalid reason code in PUBREC", ReasonCodes::ProtocolError);
2314+
}
2315+
}
22952316
}
22962317

22972318
return result;

0 commit comments

Comments
 (0)