summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ac077f0)
raw | patch | inline | side by side (parent: ac077f0)
author | Nicholas Humfrey <njh@aelius.com> | |
Thu, 26 Nov 2015 20:29:30 +0000 (20:29 +0000) | ||
committer | Nicholas Humfrey <njh@aelius.com> | |
Thu, 26 Nov 2015 20:29:30 +0000 (20:29 +0000) |
src/mqtt.c | patch | blob | history |
diff --git a/src/mqtt.c b/src/mqtt.c
index 1b71d423d458109247e095cd8b5ce97de30b0ce4..2eb11520dce1eccca31427c5707f46e4a02bd125 100644 (file)
--- a/src/mqtt.c
+++ b/src/mqtt.c
char *payload;
int status;
- if ((msg->payloadlen <= 0)
- || (((uint8_t *) msg->payload)[msg->payloadlen - 1] != 0))
+ if (msg->payloadlen <= 0) {
+ DEBUG ("mqtt plugin: message has empty payload");
return;
+ }
topic = strdup (msg->topic);
name = strip_prefix (topic);
}
vl.values_len = ds->ds_num;
- payload = strdup ((void *) msg->payload);
+ payload = malloc (msg->payloadlen+1);
+ if (payload == NULL)
+ {
+ ERROR ("mqtt plugin: malloc for payload buffer failed.");
+ return;
+ }
+ memmove (payload, msg->payload, msg->payloadlen);
+ payload[msg->payloadlen] = 0;
+
DEBUG ("mqtt plugin: payload = \"%s\"", payload);
status = parse_values (payload, &vl, ds);
if (status != 0)