In parse_identifier_vl function (common.c), the value passed to
sstrncpy as buffer length is the sizeof a char pointer, which
is 4bytes for 32bit arch and 8bytes for 64 bit ones.

This patch fix the length and truncate the buffer to the same size as
destination buffer.

Signed-off-by: Andres J. Diaz <[email protected]>
---
 src/common.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/common.c b/src/common.c
index 6fdb441..7015c87 100644
--- a/src/common.c
+++ b/src/common.c
@@ -939,15 +939,15 @@ int parse_identifier_vl (const char *str, value_list_t 
*vl) /* {{{ */
        if (status != 0)
                return (status);
 
-       sstrncpy (vl->host, host, sizeof (host));
-       sstrncpy (vl->plugin, plugin, sizeof (plugin));
+       sstrncpy (vl->host, host, sizeof (vl->host));
+       sstrncpy (vl->plugin, plugin, sizeof (vl->plugin));
        sstrncpy (vl->plugin_instance,
                        (plugin_instance != NULL) ? plugin_instance : "",
-                       sizeof (plugin_instance));
-       sstrncpy (vl->type, type, sizeof (type));
+                       sizeof (vl->plugin_instance));
+       sstrncpy (vl->type, type, sizeof (vl->type));
        sstrncpy (vl->type_instance,
                        (type_instance != NULL) ? type_instance : "",
-                       sizeof (type_instance));
+                       sizeof (vl->type_instance));
 
        return (0);
 } /* }}} int parse_identifier_vl */
-- 
1.7.1


_______________________________________________
collectd mailing list
[email protected]
http://mailman.verplant.org/listinfo/collectd

Reply via email to