Validate MsgId of PUBLISH

MsgId of QoS0 or QoS-1 should be 0.

Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
tomoaki
2019-08-24 17:33:42 +09:00
parent 22e7f0d272
commit 2067e6fe92

View File

@@ -94,6 +94,12 @@ MQTTGWPacket* MQTTSNPublishHandler::handlePublish(Client* client, MQTTSNPacket*
return nullptr;
}
if ( ( qos == 0 || qos == 3 ) && msgId > 0 )
{
WRITELOG("%s Invalid MsgId.%s %s\n", ERRMSG_HEADER, client->getClientId(), ERRMSG_FOOTER);
return nullptr;
}
if( !topic && msgId && qos > 0 && qos < 3 )
{
/* Reply PubAck with INVALID_TOPIC_ID to the client */