[collectd] [PATCHES] fixing thermal plugin and a small bug

Markus Knetschke markus.knetschke at gmail.com
Sun Dec 23 13:10:44 CET 2012


Hi,

The first two patches fixing the thermal plugin which broke in
7ef8f8ed456a9a1a6cfd5b9da04836
bf867d6842 (Feb 24, 2009)

The third fixed a possible NULL pointer dereference.

Thanks,
Markus Knetschke

>From e0b0da95110e9a3c2e234686b31703532228082d Mon Sep 17 00:00:00 2001
From: Markus Knetschke <markus.knetschke at gmail.com>
Date: Sun, 23 Dec 2012 11:02:42 +0100
Subject: [PATCH 1/3] thermal plugin: fixed value submitting


Signed-off-by: Markus Knetschke <markus.knetschke at gmail.com>
---
 src/thermal.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/thermal.c b/src/thermal.c
index 0ad0d90..c2ce983 100644
--- a/src/thermal.c
+++ b/src/thermal.c
@@ -55,6 +55,8 @@ static void thermal_submit (const char
*plugin_instance, enum dev_type dt,
     v.gauge = value;
     vl.values = &v;

+    vl.values_len = 1;
+
     sstrncpy (vl.plugin, "thermal", sizeof(vl.plugin));
     if (plugin_instance != NULL)
         sstrncpy (vl.plugin_instance, plugin_instance,
--
1.8.0.2



>From 09164921bdc5bf40d5e75bb4bc397ffafe22ee82 Mon Sep 17 00:00:00 2001
From: Markus Knetschke <markus.knetschke at gmail.com>
Date: Sun, 23 Dec 2012 11:50:22 +0100
Subject: [PATCH 2/3] thermal plugin: set the hostname


Signed-off-by: Markus Knetschke <markus.knetschke at gmail.com>
---
 src/thermal.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/thermal.c b/src/thermal.c
index c2ce983..603f85b 100644
--- a/src/thermal.c
+++ b/src/thermal.c
@@ -57,6 +57,7 @@ static void thermal_submit (const char
*plugin_instance, enum dev_type dt,

     vl.values_len = 1;

+    sstrncpy (vl.host, hostname_g, sizeof (vl.host));
     sstrncpy (vl.plugin, "thermal", sizeof(vl.plugin));
     if (plugin_instance != NULL)
         sstrncpy (vl.plugin_instance, plugin_instance,
--
1.8.0.2


>From d65cb6407c536077ecc67c37552d3c26cbbc8880 Mon Sep 17 00:00:00 2001
From: Markus Knetschke <markus.knetschke at gmail.com>
Date: Sun, 23 Dec 2012 11:59:45 +0100
Subject: [PATCH 3/3] Fixed NULL pointer dereference bug in
 plugin_dispatch_values


Signed-off-by: Markus Knetschke <markus.knetschke at gmail.com>
---
 src/plugin.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/plugin.c b/src/plugin.c
index bbede05..eb25066 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -1502,8 +1502,15 @@ int plugin_dispatch_values (value_list_t *vl)

     int free_meta_data = 0;

-    if ((vl == NULL) || (vl->type[0] == 0)
-            || (vl->values == NULL) || (vl->values_len < 1))
+    if((vl == NULL) || (vl->plugin == NULL))
+    {
+        ERROR ("plugin_dispatch_values: Invalid value list "
+                "from unknown plugin.");
+        return (-1);
+    }
+
+    if ((vl->type[0] == 0) || (vl->values == NULL)
+        || (vl->values_len < 1))
     {
         ERROR ("plugin_dispatch_values: Invalid value list "
                 "from plugin %s.", vl->plugin);
--
1.8.0.2



More information about the collectd mailing list