Code

patches: add mqtt_invalid_symbols.patch
authorMarc Fournier <marc@bl.uem.li>
Mon, 23 Jan 2017 19:23:51 +0000 (20:23 +0100)
committerMarc Fournier <marc@bl.uem.li>
Mon, 23 Jan 2017 19:44:43 +0000 (20:44 +0100)
debian/changelog
debian/patches/mqtt_invalid_symbols.patch [new file with mode: 0644]
debian/patches/series

index c3e61f605ecd7028f15f46befd753a1f4d035624..434f19b05c67daa6bd4949c597c4258e650d8d62 100644 (file)
@@ -4,6 +4,8 @@ collectd (5.7.1-1) UNRELEASED; urgency=medium
   * debian/patches:
     - drop dpdkstat-portable-format-string.patch, included upstream.
     - add mqtt_resource_leak.patch, fixing a connection leak.
+    - add mqtt_invalid_symbols.patch, stripping out invalid characters from
+      MQTT topic names.
 
  -- Marc Fournier <marc@bl.uem.li>  Mon, 23 Jan 2017 09:23:07 +0100
 
diff --git a/debian/patches/mqtt_invalid_symbols.patch b/debian/patches/mqtt_invalid_symbols.patch
new file mode 100644 (file)
index 0000000..5adce34
--- /dev/null
@@ -0,0 +1,26 @@
+Description: mqtt plugin: Fix invalid symbols in topic name.
+Author: Denys Fedoryshchenko <denys@visp.net.lb>
+
+diff --git a/src/mqtt.c b/src/mqtt.c
+index 6b76af97b..8a24ccaa0 100644
+--- a/src/mqtt.c
++++ b/src/mqtt.c
+@@ -462,6 +462,7 @@ static int format_topic(char *buf, size_t buf_len, data_set_t const *ds,
+                         value_list_t const *vl, mqtt_client_conf_t *conf) {
+   char name[MQTT_MAX_TOPIC_SIZE];
+   int status;
++  char *c;
+   if ((conf->topic_prefix == NULL) || (conf->topic_prefix[0] == 0))
+     return (FORMAT_VL(buf, buf_len, vl));
+@@ -474,6 +475,10 @@ static int format_topic(char *buf, size_t buf_len, data_set_t const *ds,
+   if ((status < 0) || (((size_t)status) >= buf_len))
+     return (ENOMEM);
++  while((c = strchr(buf, '#')) || (c = strchr(buf, '+'))) {
++       *c = '_';
++  }
++
+   return (0);
+ } /* int format_topic */
index b0cc80c093f4f6760ea0e503eb377c63ea2b6d6d..afc72edf62c18448e85ea0e74b46b5f0a7c1b2e2 100644 (file)
@@ -3,3 +3,4 @@ collection_conf_path.patch
 myplugin_includes.patch
 nagios-debian-paths.patch
 mqtt_resource_leak.patch
+mqtt_invalid_symbols.patch