paho.mqtt.c
paho.mqtt.c copied to clipboard
MQTTAsync_processCommand crashes when a previously persisted PUBLISH command cannot be retrieved
Describe the bug
MQTTAsync_processCommand
crashes when a previously persisted PUBLISH command cannot be retrieved. In our case, the key string got corrupted so the outcome was as if the file was missing. This causes a nullptr dereference down the line within MQTTProtocol_storePublication
.
To Reproduce I'm not able to reproduce the corrupted key string issue, but I can force the bug to appear by:
- Bring the broker down
- Persist some commands
- Delete some of the persisted commands
- Start the broker, on automatic reconnect the crash appears
Expected behavior
MQTTAsync_processCommand
should have additional handling in place for PUBLISH pget failures. I'm not sure how the other command types are handled, but I would think it should just bail out if the persistence fails to retrieve a PUBLISH command.
Screenshots
Environment
- Microsoft Visual Studio Professional 2022 (64-bit) - LTSC 17.4 (Version 17.4.7)
- Windows SDK version 10.0.22000.0 to target Windows 10.0.19045.
- MSVC_VERSION 1934 (v143 toolset)
Additional context We are using the paho mqtt cpp library. I don't have a log file to show at the moment.