eclipse-paho / paho.mqtt.c

An Eclipse Paho C client library for MQTT for Windows, Linux and MacOS. API documentation: https://eclipse.github.io/paho.mqtt.c/
https://eclipse.org/paho
Other
1.97k stars 1.1k forks source link

MQTTv5:When giving MQTTCLIENT_PERSISTENCE_DEFAULT with createWithOptions, MQTTPacket_send_subscribe qoss is coming NULL #1086

Closed bansalaj closed 3 years ago

bansalaj commented 3 years ago

Describe the bug Paho code is crashing while accessing qoss list element in MQTTPacket_send_subscribe(). Connection with MQTTBroker was made with createOption where persistence was set to MQTTCLIENT_PERSISTENCE_DEFAULT. Then MQTTAsync_subscribe is called with topic value and qos level. As the persistence is set to MQTTCLIENT_PERSISTENCE_DEFAULT it tries to write the information, As the MQTT version is 5 it only stores topic and other values but not the qoss value. And same while retrieving the command from persistence. And so in MQTTPacket_send_subscribe() the code crashes as List* qoss points to invalid address

To Reproduce Create a Async client connection with MQTTAsync_createWithOptions with values MQTTCLIENT_PERSISTENCE_DEFAULT along with MQTTversion 5

Send a async subcribe request with MQTTAsync_subscribe with qos values 1 or 2

Expected behavior A connack response and successfull subscription of the topic.

Screenshots InvalidPointer

callstack

Environment (please complete the following information):

Works Fine with When using MQTTCLIENT_PERSISTENCE_NONE instead of default it works perfectly fine

bansalaj commented 3 years ago

I deleted the messages(persistence backup) from the folder and now it is working fine. Don't what was the issue but now it is not reproducible