Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from nscooling/master
Browse files Browse the repository at this point in the history
Fixed '\0' error
  • Loading branch information
nscooling committed Feb 5, 2013
2 parents 9df17d1 + 9b5e8c0 commit 2c9ccd1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/mqtt.c
Expand Up @@ -277,14 +277,13 @@ int mqtt_publish(mqtt_broker_handle_t *broker, const char *topic, const char *ms
}

// utf topic
uint8_t utf_topic[2+strlen(topic)+1]; // 2 for message size + 1 for '\0'
uint8_t utf_topic[2+strlen(topic)]; // 2 for message size QoS-0 does not have msg ID

// set up topic payload
utf_topic[0] = 0; // MSB(strlen(topic));
utf_topic[1] = LSB(strlen(topic));
strcpy((char *)&utf_topic[2], topic);
utf_topic[sizeof(utf_topic)-1] = '\0'; // terminate topic str correctly


uint8_t fixed_header[] = { SET_MESSAGE(PUBLISH), sizeof(utf_topic)+strlen(msg)};
// fixed_header_t fixed_header = { .QoS = 0, .connect_msg_t = PUBLISH, .remaining_length = sizeof(utf_topic)+strlen(msg) };

Expand Down

0 comments on commit 2c9ccd1

Please sign in to comment.