From: Florian Forster Date: Sun, 6 Jul 2008 14:17:27 +0000 (+0200) Subject: Merge branch 'collectd-4.4' X-Git-Tag: collectd-4.5.0~99 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=10075e6fe3c384b73c2dd398a1435f8d10e56654 Merge branch 'collectd-4.4' Conflicts: src/apache.c src/apcups.c src/apple_sensors.c src/battery.c src/cpu.c src/cpufreq.c src/df.c src/disk.c src/dns.c src/email.c src/entropy.c src/hddtemp.c src/interface.c src/ipvs.c src/irq.c src/load.c src/mbmon.c src/memcached.c src/memory.c src/multimeter.c src/mysql.c src/netlink.c src/network.c src/nfs.c src/nginx.c src/ntpd.c src/nut.c src/ping.c src/processes.c src/rrdtool.c src/serial.c src/snmp.c src/swap.c src/tape.c src/tcpconns.c src/users.c src/utils_cmd_putval.c src/vserver.c src/wireless.c src/xmms.c --- 10075e6fe3c384b73c2dd398a1435f8d10e56654 diff --cc src/apache.c index 7667f247,a2f41f4b..c6bf8add --- a/src/apache.c +++ b/src/apache.c @@@ -198,16 -199,18 +198,16 @@@ static void submit_counter (const char vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "apache"); - strcpy (vl.plugin_instance, ""); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "apache", sizeof (vl.plugin)); + sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); if (type_instance != NULL) - { - strncpy (vl.type_instance, type_instance, + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - vl.type_instance[sizeof (vl.type_instance) - 1] = '\0'; - } - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void submit_counter */ static void submit_gauge (const char *type, const char *type_instance, @@@ -221,16 -224,18 +221,16 @@@ vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "apache"); - strcpy (vl.plugin_instance, ""); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "apache", sizeof (vl.plugin)); + sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); if (type_instance != NULL) - { - strncpy (vl.type_instance, type_instance, + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - vl.type_instance[sizeof (vl.type_instance) - 1] = '\0'; - } - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void submit_counter */ static void submit_scoreboard (char *buf) diff --cc src/apcups.c index fb481092,c948f5a1..227c703c --- a/src/apcups.c +++ b/src/apcups.c @@@ -372,13 -373,12 +372,13 @@@ static void apc_submit_generic (char *t vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "apcups"); - strcpy (vl.plugin_instance, ""); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "apcups", sizeof (vl.plugin)); + sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); - strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); + sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } static void apc_submit (struct apc_detail_s *apcups_detail) diff --cc src/apple_sensors.c index ee0bf8c0,5e957b6f..62963358 --- a/src/apple_sensors.c +++ b/src/apple_sensors.c @@@ -88,13 -88,12 +88,13 @@@ static void as_submit (const char *type vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "apple_sensors"); - strcpy (vl.plugin_instance, ""); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "apple_sensors", sizeof (vl.plugin)); + sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)) sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } static int as_read (void) diff --cc src/battery.c index 74b3344a,badd8e75..9f1bee65 --- a/src/battery.c +++ b/src/battery.c @@@ -99,12 -98,11 +99,12 @@@ static void battery_submit (const char vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "battery"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "battery", sizeof (vl.plugin)); sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void battery_submit */ #if HAVE_IOKIT_PS_IOPOWERSOURCES_H || HAVE_IOKIT_IOKITLIB_H diff --cc src/cpu.c index 7773dc41,0fadc064..e9ab7832 --- a/src/cpu.c +++ b/src/cpu.c @@@ -180,14 -180,14 +180,14 @@@ static void submit (int cpu_num, const vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "cpu"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "cpu", sizeof (vl.plugin)); - snprintf (vl.plugin_instance, sizeof (vl.type_instance), + ssnprintf (vl.plugin_instance, sizeof (vl.type_instance), "%i", cpu_num); - strcpy (vl.type, "cpu"); - vl.plugin_instance[DATA_MAX_NAME_LEN - 1] = '\0'; ++ sstrncpy (vl.type, "cpu", sizeof (vl.type)); sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values ("cpu", &vl); + plugin_dispatch_values (&vl); } static int cpu_read (void) diff --cc src/cpufreq.c index f4424e65,74e542b4..3738b54c --- a/src/cpufreq.c +++ b/src/cpufreq.c @@@ -68,13 -68,12 +68,13 @@@ static void cpufreq_submit (int cpu_num vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "cpufreq"); - strcpy (vl.type, "cpufreq"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "cpufreq", sizeof (vl.plugin)); - snprintf (vl.type_instance, sizeof (vl.type_instance), ++ sstrncpy (vl.type, "cpufreq", sizeof (vl.type)); + ssnprintf (vl.type_instance, sizeof (vl.type_instance), "%i", cpu_num); - plugin_dispatch_values ("cpufreq", &vl); + plugin_dispatch_values (&vl); } static int cpufreq_read (void) diff --cc src/df.c index 284472b1,6bd92500..26d23826 --- a/src/df.c +++ b/src/df.c @@@ -125,13 -125,12 +125,13 @@@ static void df_submit (char *df_name vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "df"); - strcpy (vl.plugin_instance, ""); - strcpy (vl.type, "df"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "df", sizeof (vl.plugin)); + sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); - strncpy (vl.type_instance, df_name, sizeof (vl.type_instance)); ++ sstrncpy (vl.type, "df", sizeof (vl.host)); + sstrncpy (vl.type_instance, df_name, sizeof (vl.type_instance)); - plugin_dispatch_values ("df", &vl); + plugin_dispatch_values (&vl); } /* void df_submit */ static int df_read (void) diff --cc src/disk.c index a6f850a1,20afd30b..29aa9790 --- a/src/disk.c +++ b/src/disk.c @@@ -213,13 -213,12 +213,13 @@@ static void disk_submit (const char *pl vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "disk"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "disk", sizeof (vl.plugin)); - strncpy (vl.plugin_instance, plugin_instance, + sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void disk_submit */ #if HAVE_IOKIT_IOKITLIB_H diff --cc src/dns.c index c315eab9,69cb1922..c04169fe --- a/src/dns.c +++ b/src/dns.c @@@ -299,12 -299,11 +299,12 @@@ static void submit_counter (const char vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "dns"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "dns", sizeof (vl.plugin)); - strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void submit_counter */ static void submit_octets (counter_t queries, counter_t responses) @@@ -318,11 -317,10 +318,11 @@@ vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "dns"); - strcpy (vl.type, "dns_octets"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "dns", sizeof (vl.plugin)); ++ sstrncpy (vl.type, "dns_octets", sizeof (vl.type)); - plugin_dispatch_values ("dns_octets", &vl); + plugin_dispatch_values (&vl); } /* void submit_counter */ static int dns_read (void) diff --cc src/email.c index fbdc785f,0882ad46..e208f130 --- a/src/email.c +++ b/src/email.c @@@ -394,9 -390,9 +390,7 @@@ static void *open_connection (void *arg } addr.sun_family = AF_UNIX; -- - strncpy (addr.sun_path, path, (size_t)(UNIX_PATH_MAX - 1)); - addr.sun_path[UNIX_PATH_MAX - 1] = '\0'; + sstrncpy (addr.sun_path, path, (size_t)(UNIX_PATH_MAX - 1)); - unlink (addr.sun_path); errno = 0; if (-1 == bind (connector_socket, (struct sockaddr *)&addr, @@@ -657,12 -653,11 +651,12 @@@ static void email_submit (const char *t vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "email"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "email", sizeof (vl.plugin)); - strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void email_submit */ /* Copy list l1 to list l2. l2 may partly exist already, but it is assumed diff --cc src/entropy.c index 85d41cfc,69ce3142..2e20a67c --- a/src/entropy.c +++ b/src/entropy.c @@@ -39,13 -39,12 +39,11 @@@ static void entropy_submit (double entr vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "entropy"); - strcpy (vl.plugin_instance, ""); - strcpy (vl.type, "entropy"); - strcpy (vl.type_instance, ""); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "entropy", sizeof (vl.plugin)); - sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); - sstrncpy (vl.type_instance, "", sizeof (vl.type_instance)); ++ sstrncpy (vl.type, "entropy", sizeof (vl.type)); - plugin_dispatch_values ("entropy", &vl); + plugin_dispatch_values (&vl); } static int entropy_read (void) diff --cc src/hddtemp.c index a9c09418,cb495770..9f4a7254 --- a/src/hddtemp.c +++ b/src/hddtemp.c @@@ -448,12 -449,11 +448,12 @@@ static void hddtemp_submit (char *type_ vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "hddtemp"); - strcpy (vl.type, "temperature"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "hddtemp", sizeof (vl.plugin)); - strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); ++ sstrncpy (vl.type, "temperature", sizeof (vl.type)); + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values ("temperature", &vl); + plugin_dispatch_values (&vl); } static int hddtemp_read (void) diff --cc src/interface.c index ff4a0aa1,2add89d7..806a336d --- a/src/interface.c +++ b/src/interface.c @@@ -197,12 -197,11 +197,12 @@@ static void if_submit (const char *dev vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "interface"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "interface", sizeof (vl.plugin)); - strncpy (vl.type_instance, dev, sizeof (vl.type_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); + sstrncpy (vl.type_instance, dev, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void if_submit */ static int interface_read (void) diff --cc src/iptables.c index dc69f6be,ea8c65e9..4d15c6e0 --- a/src/iptables.c +++ b/src/iptables.c @@@ -219,10 -221,10 +219,10 @@@ static int submit_match (const struct i vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "iptables"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "iptables", sizeof (vl.plugin)); - status = snprintf (vl.plugin_instance, sizeof (vl.plugin_instance), + status = ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance), "%s-%s", chain->table, chain->chain); if ((status < 1) || ((unsigned int)status >= sizeof (vl.plugin_instance))) return (0); @@@ -234,20 -236,19 +234,20 @@@ else { if (chain->rule_type == RTYPE_NUM) - snprintf (vl.type_instance, sizeof (vl.type_instance), + ssnprintf (vl.type_instance, sizeof (vl.type_instance), "%i", chain->rule.num); else - strncpy (vl.type_instance, (char *) match->data, + sstrncpy (vl.type_instance, (char *) match->data, sizeof (vl.type_instance)); } - vl.type_instance[sizeof (vl.type_instance) - 1] = '\0'; - strcpy (vl.type, "ipt_bytes"); ++ sstrncpy (vl.type, "ipt_bytes", sizeof (vl.type)); values[0].counter = (counter_t) entry->counters.bcnt; - plugin_dispatch_values ("ipt_bytes", &vl); + plugin_dispatch_values (&vl); - strcpy (vl.type, "ipt_packets"); ++ sstrncpy (vl.type, "ipt_packets", sizeof (vl.type)); values[0].counter = (counter_t) entry->counters.pcnt; - plugin_dispatch_values ("ipt_packets", &vl); + plugin_dispatch_values (&vl); return (0); } /* void submit_match */ diff --cc src/ipvs.c index a64e7b7a,31e97415..10c4d151 --- a/src/ipvs.c +++ b/src/ipvs.c @@@ -238,14 -238,12 +238,14 @@@ static void cipvs_submit_connections (c vl.time = time (NULL); vl.interval = interval_g; - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "ipvs"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "ipvs", sizeof (vl.plugin)); sstrncpy (vl.plugin_instance, pi, sizeof (vl.plugin_instance)); - strcpy (vl.type, "connections"); - sstrncpy (vl.type_instance, (NULL != ti) ? ti : "total", sizeof (vl.type_instance)); ++ sstrncpy (vl.type, "connections", sizeof (vl.type)); + sstrncpy (vl.type_instance, (NULL != ti) ? ti : "total", + sizeof (vl.type_instance)); - plugin_dispatch_values ("connections", &vl); + plugin_dispatch_values (&vl); return; } /* cipvs_submit_connections */ @@@ -264,14 -262,12 +264,14 @@@ static void cipvs_submit_if (char *pi, vl.time = time (NULL); vl.interval = interval_g; - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "ipvs"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "ipvs", sizeof (vl.plugin)); sstrncpy (vl.plugin_instance, pi, sizeof (vl.plugin_instance)); - sstrncpy (vl.type_instance, (NULL != ti) ? ti : "total", sizeof (vl.type_instance)); + sstrncpy (vl.type, t, sizeof (vl.type)); + sstrncpy (vl.type_instance, (NULL != ti) ? ti : "total", + sizeof (vl.type_instance)); - plugin_dispatch_values (t, &vl); + plugin_dispatch_values (&vl); return; } /* cipvs_submit_if */ diff --cc src/irq.c index 792ac346,93c6076b..9b7e6187 --- a/src/irq.c +++ b/src/irq.c @@@ -132,11 -132,10 +132,11 @@@ static void irq_submit (unsigned int ir vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "irq"); - strcpy (vl.type, "irq"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "irq", sizeof (vl.plugin)); ++ sstrncpy (vl.type, "irq", sizeof (vl.type)); - status = snprintf (vl.type_instance, sizeof (vl.type_instance), + status = ssnprintf (vl.type_instance, sizeof (vl.type_instance), "%u", irq); if ((status < 1) || ((unsigned int)status >= sizeof (vl.type_instance))) return; diff --cc src/load.c index 7d11b986,e0e0c0ed..72c7756a --- a/src/load.c +++ b/src/load.c @@@ -51,11 -51,10 +51,11 @@@ static void load_submit (gauge_t snum, vl.values = values; vl.values_len = STATIC_ARRAY_SIZE (values); vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "load"); - strcpy (vl.type, "load"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "load", sizeof (vl.plugin)); ++ sstrncpy (vl.type, "load", sizeof (vl.type)); - plugin_dispatch_values ("load", &vl); + plugin_dispatch_values (&vl); } static int load_read (void) diff --cc src/mbmon.c index 923118f6,22a26da5..344caddf --- a/src/mbmon.c +++ b/src/mbmon.c @@@ -228,12 -228,11 +228,12 @@@ static void mbmon_submit (const char *t vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "mbmon"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "mbmon", sizeof (vl.plugin)); - strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void mbmon_submit */ /* Trim trailing whitespace from a string. */ diff --cc src/memcached.c index ca93102f,c830598d..ddea2ea2 --- a/src/memcached.c +++ b/src/memcached.c @@@ -223,13 -224,15 +223,13 @@@ static void submit_counter (const char vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "memcached"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin)); + sstrncpy (vl.type, type, sizeof (vl.type)); if (type_inst != NULL) - { - strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance)); - vl.type_instance[sizeof (vl.type_instance) - 1] = '\0'; - } + sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void memcached_submit_cmd */ /* }}} */ @@@ -245,13 -248,15 +245,13 @@@ static void submit_counter2 (const cha vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "memcached"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin)); + sstrncpy (vl.type, type, sizeof (vl.type)); if (type_inst != NULL) - { - strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance)); - vl.type_instance[sizeof (vl.type_instance) - 1] = '\0'; - } + sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void memcached_submit_cmd */ /* }}} */ @@@ -266,13 -271,15 +266,13 @@@ static void submit_gauge (const char *t vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "memcached"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin)); + sstrncpy (vl.type, type, sizeof (vl.type)); if (type_inst != NULL) - { - strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance)); - vl.type_instance[sizeof (vl.type_instance) - 1] = '\0'; - } + sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* }}} */ @@@ -288,13 -295,15 +288,13 @@@ static void submit_gauge2 (const char * vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "memcached"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin)); + sstrncpy (vl.type, type, sizeof (vl.type)); if (type_inst != NULL) - { - strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance)); - vl.type_instance[sizeof (vl.type_instance) - 1] = '\0'; - } + sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* }}} */ diff --cc src/memory.c index b56fc5a3,583f71a2..c1564c86 --- a/src/memory.c +++ b/src/memory.c @@@ -109,12 -109,12 +109,12 @@@ static void memory_submit (const char * vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "memory"); - strcpy (vl.type, "memory"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "memory", sizeof (vl.plugin)); - strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - vl.type_instance[sizeof (vl.type_instance) - 1] = '\0'; ++ sstrncpy (vl.type, "memory", sizeof (vl.type)); + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values ("memory", &vl); + plugin_dispatch_values (&vl); } static int memory_read (void) diff --cc src/multimeter.c index e09d9f98,c6b070a0..994747f9 --- a/src/multimeter.c +++ b/src/multimeter.c @@@ -216,11 -216,10 +216,11 @@@ static void multimeter_submit (double v vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "multimeter"); - strcpy (vl.type, "multimeter"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "multimeter", sizeof (vl.plugin)); ++ sstrncpy (vl.type, "multimeter", sizeof (vl.type)); - plugin_dispatch_values ("multimeter", &vl); + plugin_dispatch_values (&vl); } static int multimeter_read (void) diff --cc src/mysql.c index 444acaa2,aa585d65..312a819e --- a/src/mysql.c +++ b/src/mysql.c @@@ -126,12 -126,11 +126,12 @@@ static void counter_submit (const char 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)); - strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void counter_submit */ static void qcache_submit (counter_t hits, counter_t inserts, @@@ -150,11 -149,10 +150,11 @@@ 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 ("mysql_qcache", &vl); + plugin_dispatch_values (&vl); } /* void qcache_submit */ static void threads_submit (gauge_t running, gauge_t connected, gauge_t cached, @@@ -171,11 -169,10 +171,11 @@@ 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 ("mysql_threads", &vl); + plugin_dispatch_values (&vl); } /* void threads_submit */ static void traffic_submit (counter_t rx, counter_t tx) @@@ -189,11 -186,10 +189,11 @@@ 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 ("mysql_octets", &vl); + plugin_dispatch_values (&vl); } /* void traffic_submit */ static int mysql_read (void) diff --cc src/netlink.c index d621da5b,e54365d0..c2e4c9b4 --- a/src/netlink.c +++ b/src/netlink.c @@@ -171,15 -171,14 +171,15 @@@ static void submit_one (const char *dev vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "netlink"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "netlink", sizeof (vl.plugin)); - strncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance)); + sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); if (type_instance != NULL) - strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void submit_one */ static void submit_two (const char *dev, const char *type, @@@ -195,15 -194,14 +195,15 @@@ vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "netlink"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "netlink", sizeof (vl.plugin)); - strncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance)); + sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); if (type_instance != NULL) - strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void submit_two */ static int link_filter (const struct sockaddr_nl *sa, diff --cc src/network.c index b6778fa0,0f558ca9..39069aa7 --- a/src/network.c +++ b/src/network.c @@@ -1436,15 -1438,15 +1436,15 @@@ static int add_to_buffer (char *buffer vl->plugin_instance, strlen (vl->plugin_instance)) != 0) return (-1); - strcpy (vl_def->plugin_instance, vl->plugin_instance); + sstrncpy (vl_def->plugin_instance, vl->plugin_instance, sizeof (vl_def->plugin_instance)); } - if (strcmp (type_def, ds->type) != 0) + if (strcmp (type_def, vl->type) != 0) { if (write_part_string (&buffer, &buffer_size, TYPE_TYPE, - ds->type, strlen (ds->type)) != 0) + vl->type, strlen (vl->type)) != 0) return (-1); - strcpy (type_def, vl->type); - sstrncpy (type_def, ds->type, sizeof (type_def)); ++ sstrncpy (type_def, vl->type, sizeof (type_def)); } if (strcmp (vl_def->type_instance, vl->type_instance) != 0) diff --cc src/nfs.c index 34f01f43,91e67886..f2db895a --- a/src/nfs.c +++ b/src/nfs.c @@@ -188,11 -188,10 +188,11 @@@ static void nfs_procedures_submit (cons vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "nfs"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "nfs", sizeof (vl.plugin)); - strncpy (vl.plugin_instance, plugin_instance, + sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); - strcpy (vl.type, "nfs_procedure"); ++ sstrncpy (vl.type, "nfs_procedure", sizeof (vl.type)); for (i = 0; i < len; i++) { diff --cc src/nginx.c index 4de59f37,283e8f6f..91bcf754 --- a/src/nginx.c +++ b/src/nginx.c @@@ -178,15 -177,17 +178,15 @@@ static void submit (char *type, char *i vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "nginx"); - strcpy (vl.plugin_instance, ""); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "nginx", sizeof (vl.plugin)); + sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); if (inst != NULL) - { - strncpy (vl.type_instance, inst, sizeof (vl.type_instance)); - vl.type_instance[sizeof (vl.type_instance) - 1] = '\0'; - } + sstrncpy (vl.type_instance, inst, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void submit */ static int nginx_read (void) diff --cc src/ntpd.c index 9475ac91,69b949b1..22bbc5d1 --- a/src/ntpd.c +++ b/src/ntpd.c @@@ -301,13 -302,12 +301,13 @@@ static void ntpd_submit (char *type, ch vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "ntpd"); - strcpy (vl.plugin_instance, ""); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "ntpd", sizeof (vl.plugin)); + sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); - strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); + sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* returns `tv0 - tv1' in milliseconds or 0 if `tv1 > tv0' */ diff --cc src/nut.c index 75504d40,695d93b5..8796d587 --- a/src/nut.c +++ b/src/nut.c @@@ -129,12 -129,15 +129,12 @@@ static void nut_submit (nut_ups_t *ups ? hostname_g : ups->hostname, sizeof (vl.host)); - strcpy (vl.plugin, "nut"); + sstrncpy (vl.plugin, "nut", sizeof (vl.plugin)); - strncpy (vl.plugin_instance, ups->upsname, sizeof (vl.plugin_instance)); - strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); + sstrncpy (vl.plugin_instance, ups->upsname, sizeof (vl.plugin_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - vl.host[sizeof (vl.host) - 1] = '\0'; - vl.plugin_instance[sizeof (vl.plugin_instance) - 1] = '\0'; - vl.type_instance[sizeof (vl.type_instance) - 1] = '\0'; - - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void nut_submit */ static int nut_read_one (nut_ups_t *ups) diff --cc src/perl.c index 3a56da62,597368f1..541826fb --- a/src/perl.c +++ b/src/perl.c @@@ -564,24 -555,29 +564,24 @@@ static int pplugin_dispatch_values (pTH } if (NULL != (tmp = hv_fetch (values, "host", 4, 0))) { - strncpy (list.host, SvPV_nolen (*tmp), DATA_MAX_NAME_LEN); - list.host[DATA_MAX_NAME_LEN - 1] = '\0'; + sstrncpy (list.host, SvPV_nolen (*tmp), sizeof (list.host)); } else { - strcpy (list.host, hostname_g); + sstrncpy (list.host, hostname_g, sizeof (list.host)); } - if (NULL != (tmp = hv_fetch (values, "plugin", 6, 0))) { - strncpy (list.plugin, SvPV_nolen (*tmp), DATA_MAX_NAME_LEN); - list.plugin[DATA_MAX_NAME_LEN - 1] = '\0'; - } + if (NULL != (tmp = hv_fetch (values, "plugin", 6, 0))) + sstrncpy (list.plugin, SvPV_nolen (*tmp), sizeof (list.plugin)); - if (NULL != (tmp = hv_fetch (values, "plugin_instance", 15, 0))) { - strncpy (list.plugin_instance, SvPV_nolen (*tmp), DATA_MAX_NAME_LEN); - list.plugin_instance[DATA_MAX_NAME_LEN - 1] = '\0'; - } + if (NULL != (tmp = hv_fetch (values, "plugin_instance", 15, 0))) + sstrncpy (list.plugin_instance, SvPV_nolen (*tmp), + sizeof (list.plugin_instance)); - if (NULL != (tmp = hv_fetch (values, "type_instance", 13, 0))) { - strncpy (list.type_instance, SvPV_nolen (*tmp), DATA_MAX_NAME_LEN); - list.type_instance[DATA_MAX_NAME_LEN - 1] = '\0'; - } + if (NULL != (tmp = hv_fetch (values, "type_instance", 13, 0))) + sstrncpy (list.type_instance, SvPV_nolen (*tmp), + sizeof (list.type_instance)); - ret = plugin_dispatch_values (name, &list); + ret = plugin_dispatch_values (&list); sfree (val); return ret; diff --cc src/ping.c index 20388c37,09de77ce..ac5b0f85 --- a/src/ping.c +++ b/src/ping.c @@@ -186,13 -186,12 +186,13 @@@ static void ping_submit (char *host, do vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "ping"); - strcpy (vl.plugin_instance, ""); - strcpy (vl.type, "ping"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "ping", sizeof (vl.plugin)); + sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); - strncpy (vl.type_instance, host, sizeof (vl.type_instance)); + sstrncpy (vl.type_instance, host, sizeof (vl.type_instance)); ++ sstrncpy (vl.type, "ping", sizeof (vl.type)); - plugin_dispatch_values ("ping", &vl); + plugin_dispatch_values (&vl); } static int ping_read (void) diff --cc src/processes.c index c0d667d3,6ad46813..7531a6ae --- a/src/processes.c +++ b/src/processes.c @@@ -524,16 -409,14 +524,16 @@@ static void ps_submit_state (const cha vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "processes"); - strcpy (vl.plugin_instance, ""); - strcpy (vl.type, "ps_state"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "processes", sizeof (vl.plugin)); + sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); - strncpy (vl.type_instance, state, sizeof (vl.type_instance)); ++ sstrncpy (vl.type, "ps_state", sizeof (vl.type)); + sstrncpy (vl.type_instance, state, sizeof (vl.type_instance)); - plugin_dispatch_values ("ps_state", &vl); + plugin_dispatch_values (&vl); } +/* submit info about specific process (e.g.: memory taken, cpu usage, etc..) */ static void ps_submit_proc_list (procstat_t *ps) { value_t values[2]; @@@ -542,28 -425,24 +542,28 @@@ vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "processes"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "processes", sizeof (vl.plugin)); - strncpy (vl.plugin_instance, ps->name, sizeof (vl.plugin_instance)); + sstrncpy (vl.plugin_instance, ps->name, sizeof (vl.plugin_instance)); - strcpy (vl.type, "ps_rss"); ++ sstrncpy (vl.type, "ps_rss", sizeof (vl.type)); vl.values[0].gauge = ps->vmem_rss; vl.values_len = 1; - plugin_dispatch_values ("ps_rss", &vl); + plugin_dispatch_values (&vl); - strcpy (vl.type, "ps_cputime"); ++ sstrncpy (vl.type, "ps_cputime", sizeof (vl.type)); vl.values[0].counter = ps->cpu_user_counter; vl.values[1].counter = ps->cpu_system_counter; vl.values_len = 2; - plugin_dispatch_values ("ps_cputime", &vl); + plugin_dispatch_values (&vl); - strcpy (vl.type, "ps_count"); ++ sstrncpy (vl.type, "ps_count", sizeof (vl.type)); vl.values[0].gauge = ps->num_proc; vl.values[1].gauge = ps->num_lwp; vl.values_len = 2; - plugin_dispatch_values ("ps_count", &vl); + plugin_dispatch_values (&vl); - strcpy (vl.type, "ps_pagefaults"); ++ sstrncpy (vl.type, "ps_pagefaults", sizeof (vl.type)); vl.values[0].counter = ps->vmem_minflt_counter; vl.values[1].counter = ps->vmem_majflt_counter; vl.values_len = 2; diff --cc src/rrdtool.c index fd499fd9,3b2c54fc..7cf24367 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@@ -291,16 -284,26 +291,20 @@@ static int ds_get (char ***ret, const d } if (isnan (d->min)) - strcpy (min, "U"); + { + sstrncpy (min, "U", sizeof (min)); + } else - { - snprintf (min, sizeof (min), "%lf", d->min); - min[sizeof (min) - 1] = '\0'; - } + ssnprintf (min, sizeof (min), "%lf", d->min); if (isnan (d->max)) - strcpy (max, "U"); + { + sstrncpy (max, "U", sizeof (max)); + } else - { - snprintf (max, sizeof (max), "%lf", d->max); - max[sizeof (max) - 1] = '\0'; - } + ssnprintf (max, sizeof (max), "%lf", d->max); - status = snprintf (buffer, sizeof (buffer), + status = ssnprintf (buffer, sizeof (buffer), "DS:%s:%s:%i:%s:%s", d->name, type, (heartbeat > 0) ? heartbeat : (2 * vl->interval), diff --cc src/serial.c index 1c5d5a55,4f08a346..1c874e52 --- a/src/serial.c +++ b/src/serial.c @@@ -41,13 -41,12 +41,13 @@@ static void serial_submit (const char * vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "serial"); - strcpy (vl.type, "serial_octets"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "serial", sizeof (vl.plugin)); - strncpy (vl.type_instance, type_instance, ++ sstrncpy (vl.type, "serial_octets", sizeof (vl.type)); + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values ("serial_octets", &vl); + plugin_dispatch_values (&vl); } static int serial_read (void) diff --cc src/snmp.c index 75fa880e,6788ea9b..d19493df --- a/src/snmp.c +++ b/src/snmp.c @@@ -906,8 -907,9 +906,8 @@@ static int csnmp_dispatch_table (host_d return (-1); } - strncpy (vl.host, host->name, sizeof (vl.host)); - vl.host[sizeof (vl.host) - 1] = '\0'; + sstrncpy (vl.host, host->name, sizeof (vl.host)); - strcpy (vl.plugin, "snmp"); + sstrncpy (vl.plugin, "snmp", sizeof (vl.plugin)); vl.interval = host->interval; vl.time = time (NULL); @@@ -1295,10 -1299,11 +1295,10 @@@ static int csnmp_read_value (host_defin vl.values[i].gauge = NAN; } - strncpy (vl.host, host->name, sizeof (vl.host)); - vl.host[sizeof (vl.host) - 1] = '\0'; + sstrncpy (vl.host, host->name, sizeof (vl.host)); - strcpy (vl.plugin, "snmp"); + sstrncpy (vl.plugin, "snmp", sizeof (vl.plugin)); - strncpy (vl.type_instance, data->instance.string, sizeof (vl.type_instance)); - vl.type_instance[sizeof (vl.type_instance) - 1] = '\0'; + sstrncpy (vl.type, data->type, sizeof (vl.type)); + sstrncpy (vl.type_instance, data->instance.string, sizeof (vl.type_instance)); vl.interval = host->interval; diff --cc src/swap.c index 4f0a0ba9,4d1f24de..f9debc1b --- a/src/swap.c +++ b/src/swap.c @@@ -124,12 -124,11 +124,12 @@@ static void swap_submit (const char *ty vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "swap"); - strcpy (vl.type, "swap"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "swap", sizeof (vl.plugin)); - strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); ++ sstrncpy (vl.type, "swap", sizeof (vl.type)); + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values ("swap", &vl); + plugin_dispatch_values (&vl); } /* void swap_submit */ static int swap_read (void) diff --cc src/tape.c index 67750efc,5b5cdb46..caca537b --- a/src/tape.c +++ b/src/tape.c @@@ -69,13 -69,12 +69,13 @@@ static void tape_submit (const char *pl vl.values = values; vl.values_len = 2; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "tape"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "tape", sizeof (vl.plugin)); - strncpy (vl.plugin_instance, plugin_instance, + sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void tape_submit */ static int tape_read (void) diff --cc src/tcpconns.c index 4f46e78a,5a8f4619..655c53e5 --- a/src/tcpconns.c +++ b/src/tcpconns.c @@@ -135,9 -135,8 +135,9 @@@ static void conn_submit_port_entry (por vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "tcpconns"); - strcpy (vl.type, "tcp_connections"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "tcpconns", sizeof (vl.plugin)); ++ sstrncpy (vl.type, "tcp_connections", sizeof (vl.type)); if (((port_collect_listening != 0) && (pe->flags & PORT_IS_LISTENING)) || (pe->flags & PORT_COLLECT_LOCAL)) diff --cc src/users.c index 5b12e98c,d0bd63cd..1231075a --- a/src/users.c +++ b/src/users.c @@@ -49,11 -49,10 +49,11 @@@ static void users_submit (gauge_t value vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "users"); - strcpy (vl.type, "users"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "users", sizeof (vl.plugin)); ++ sstrncpy (vl.type, "users", sizeof (vl.plugin)); - plugin_dispatch_values ("users", &vl); + plugin_dispatch_values (&vl); } /* void users_submit */ static int users_read (void) diff --cc src/utils_cmd_putval.c index 8fbc8de3,16a09b1b..9cbba126 --- a/src/utils_cmd_putval.c +++ b/src/utils_cmd_putval.c @@@ -170,13 -171,12 +170,13 @@@ int handle_putval (FILE *fh, char **fie return (-1); } - strcpy (vl.host, hostname); - strcpy (vl.plugin, plugin); + sstrncpy (vl.host, hostname, sizeof (vl.host)); + sstrncpy (vl.plugin, plugin, sizeof (vl.plugin)); ++ sstrncpy (vl.type, type, sizeof (vl.type)); if (plugin_instance != NULL) - strcpy (vl.plugin_instance, plugin_instance); - strcpy (vl.type, type); + sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); if (type_instance != NULL) - strcpy (vl.type_instance, type_instance); + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); ds = plugin_get_ds (type); if (ds == NULL) { diff --cc src/utils_dns.c index b72cd5ca,9b001517..f2ab3377 --- a/src/utils_dns.c +++ b/src/utils_dns.c @@@ -385,7 -384,7 +385,7 @@@ handle_dns(const char *buf, int len if (0 != x) return 0; if ('\0' == qh.qname[0]) - strcpy(qh.qname, "."); - strncpy (qh.qname, ".", sizeof (qh.qname)); ++ sstrncpy (qh.qname, ".", sizeof (qh.qname)); while ((t = strchr(qh.qname, '\n'))) *t = ' '; while ((t = strchr(qh.qname, '\r'))) diff --cc src/vmem.c index 1e826a16,5341e159..25f7c70c --- a/src/vmem.c +++ b/src/vmem.c @@@ -46,11 -46,10 +46,11 @@@ static void submit (const char *plugin_ vl.values_len = values_len; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "vmem"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "vmem", sizeof (vl.plugin)); if (plugin_instance != NULL) sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); if (type_instance != NULL) sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); diff --cc src/vserver.c index 4cc82516,54843449..413674b0 --- a/src/vserver.c +++ b/src/vserver.c @@@ -57,13 -57,12 +57,13 @@@ static void traffic_submit (const char vl.values = values; vl.values_len = STATIC_ARRAY_SIZE (values); vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "vserver"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "vserver", sizeof (vl.plugin)); - strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); - strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); + sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); - strcpy (vl.type, "if_octets"); ++ sstrncpy (vl.type, "if_octets", sizeof (vl.type)); + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values ("if_octets", &vl); + plugin_dispatch_values (&vl); } /* void traffic_submit */ static void load_submit (const char *plugin_instance, @@@ -79,12 -78,11 +79,12 @@@ vl.values = values; vl.values_len = STATIC_ARRAY_SIZE (values); vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "vserver"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "vserver", sizeof (vl.plugin)); - strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); + sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); - strcpy (vl.type, "load"); ++ sstrncpy (vl.type, "load", sizeof (vl.type)); - plugin_dispatch_values ("load", &vl); + plugin_dispatch_values (&vl); } static void submit_gauge (const char *plugin_instance, const char *type, @@@ -99,13 -97,12 +99,13 @@@ vl.values = values; vl.values_len = STATIC_ARRAY_SIZE (values); vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "vserver"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "vserver", sizeof (vl.plugin)); - strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); - strncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); + sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); + sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void submit_gauge */ static inline long long __get_sock_bytes(const char *s) diff --cc src/wireless.c index a0644fe4,0edaf458..21bbcb40 --- a/src/wireless.c +++ b/src/wireless.c @@@ -56,13 -56,12 +56,13 @@@ static void wireless_submit (const cha vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "wireless"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "wireless", sizeof (vl.plugin)); - strncpy (vl.plugin_instance, plugin_instance, + sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void wireless_submit */ #define POWER_MIN -90.0 diff --cc src/xmms.c index 01c7e0cf,7f3edf0a..09786fc9 --- a/src/xmms.c +++ b/src/xmms.c @@@ -37,11 -37,10 +37,11 @@@ static void cxmms_submit (const char *t vl.values = values; vl.values_len = 1; vl.time = time (NULL); - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "xmms"); + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "xmms", sizeof (vl.plugin)); + sstrncpy (vl.type, type, sizeof (vl.type)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void cxmms_submit */ int cxmms_read (void)