rsmb
rsmb copied to clipboard
Fix crash handling publish with invalid predef topic ID.
A client publishing with an invalid predefined topic ID would crash the broker. This is caused by code added for expanding predefined topic templates. Expansion was not attempted if the original topic lookup failed, but code further down unconditionally tried to compare the original topic string (which is NULL in this case) with the expanded topic string (also NULL), resulting in a segmentation fault. Simply moving the code inside the conditional block solves the problem by falling through with topicName being NULL, which results in a proper PUBACK with the error code MQTTS_RC_REJECTED_INVALID_TOPIC_ID.