From: Andres J. Diaz Date: Tue, 1 Mar 2011 16:25:21 +0000 (+0100) Subject: Fix buffer length in parse_identifier_vl function. X-Git-Tag: collectd-5.1.0~72 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=168ba3c10031a91771b2c31a42a50d7315780edc;p=collectd.git Fix buffer length in parse_identifier_vl function. 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 Signed-off-by: Florian Forster --- diff --git a/src/common.c b/src/common.c index 6fdb441c..7015c875 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 */