X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmysql.c;h=4e72b5bf8989669cafb724ce011cc8b0a28cc2ee;hb=e628f39838a67b40d52dfb8425b4d8474fbd0550;hp=444acaa26aef33ed1d858e78564f52adec599f05;hpb=089d33f1f455da115ca0c87160df8dbd49286377;p=collectd.git diff --git a/src/mysql.c b/src/mysql.c index 444acaa2..4e72b5bf 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -24,7 +24,9 @@ #include "plugin.h" #include "configfile.h" -#ifdef HAVE_MYSQL_MYSQL_H +#ifdef HAVE_MYSQL_H +#include +#elif defined(HAVE_MYSQL_MYSQL_H) #include #endif @@ -126,8 +128,8 @@ static void counter_submit (const char *type, const char *type_instance, vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "mysql"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin)); sstrncpy (vl.type, type, sizeof (vl.type)); sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); @@ -150,9 +152,9 @@ static void qcache_submit (counter_t hits, counter_t inserts, vl.values = values; vl.values_len = 5; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "mysql"); - strcpy (vl.type, "mysql_qcache"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin)); + sstrncpy (vl.type, "mysql_qcache", sizeof (vl.type)); plugin_dispatch_values (&vl); } /* void qcache_submit */ @@ -171,9 +173,9 @@ static void threads_submit (gauge_t running, gauge_t connected, gauge_t cached, vl.values = values; vl.values_len = 4; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "mysql"); - strcpy (vl.type, "mysql_threads"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin)); + sstrncpy (vl.type, "mysql_threads", sizeof (vl.type)); plugin_dispatch_values (&vl); } /* void threads_submit */ @@ -189,9 +191,9 @@ static void traffic_submit (counter_t rx, counter_t tx) vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "mysql"); - strcpy (vl.type, "mysql_octets"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "mysql", sizeof (vl.plugin)); + sstrncpy (vl.type, "mysql_octets", sizeof (vl.type)); plugin_dispatch_values (&vl); } /* void traffic_submit */