Fix command Publish payload handling

This commit is contained in:
Theo Arends 2020-01-27 17:38:32 +01:00
parent bfb7f0c1b9
commit 42461aaaf3
1 changed files with 5 additions and 5 deletions

View File

@ -852,13 +852,13 @@ void CmndPrefix(void)
void CmndPublish(void)
{
if (XdrvMailbox.data_len > 0) {
char *mqtt_part = strtok(XdrvMailbox.data, " ");
char *payload_part;
char *mqtt_part = strtok_r(XdrvMailbox.data, " ", &payload_part);
if (mqtt_part) {
char stemp1[TOPSZ];
strlcpy(stemp1, mqtt_part, sizeof(stemp1));
mqtt_part = strtok(nullptr, " ");
if (mqtt_part) {
strlcpy(mqtt_data, mqtt_part, sizeof(mqtt_data));
if ((payload_part != nullptr) && strlen(payload_part)) {
strlcpy(mqtt_data, payload_part, sizeof(mqtt_data));
} else {
mqtt_data[0] = '\0';
}