Merge branch 'collectd-4.4'
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sun, 6 Jul 2008 14:17:27 +0000 (16:17 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sun, 6 Jul 2008 14:17:27 +0000 (16:17 +0200)
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

54 files changed:
ChangeLog
contrib/examples/MyPlugin.pm
contrib/examples/myplugin.c
src/apache.c
src/apcups.c
src/apple_sensors.c
src/ascent.c
src/battery.c
src/collectd.conf.in
src/collectd.h
src/common.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/iptables.c
src/ipvs.c
src/irq.c
src/libvirt.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/perl.c
src/ping.c
src/plugin.c
src/powerdns.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/utils_dns.c
src/vmem.c
src/vserver.c
src/wireless.c
src/xmms.c

index e960ff6..0f0f257 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,7 +8,7 @@
        * perl plugin: Fail noisily, but don't shutdown the daemon, if
          initialization has errors. An issue with Perl 5.10 has been fixed.
        * teamspeak2 plugin: Fixed an out of bounce array access. Thanks to
-         René Rebe and Siegmund Gorr for reporting this.
+         René Rebe and Siegmund Gorr for reporting this.
 
 2008-05-06, Version 4.4.0
        * collectd: Internal code cleanups.
          the data into text files rather than RRD files.
 
 2006-04-09, Version 3.8.4
-       * Applied patch by Vincent Stehlé which improves the disk-name
+       * Applied patch by Vincent Stehlé which improves the disk-name
          resolution in the `hddtemp' plugin for Linux systems.
 
 2006-04-02, Version 3.8.3
 
 2005-10-16, Version 3.1.0 (Revision 194)
        * Added the `setsid' syscall to the startup code.
-       * Support for hddtemp has been added (thanks to Vincent Stehlé)
+       * Support for hddtemp has been added (thanks to Vincent Stehlé)
 
 2005-09-30, Version 3.0.0 (Revision 184)
        * The ability to send/receive data to/from the network (think
index 1a0247f..13806ee 100644 (file)
@@ -21,7 +21,12 @@ use Collectd qw( :all );
 
 # data set definition:
 # see section "DATA TYPES" in collectd-perl(5) for details
-# (take a look at the types.db file for a large list of predefined data-sets)
+#
+# NOTE: If you're defining a custom data-set, you have to make that known to
+# any servers as well. Else, the server is not able to store values using the
+# type defined by that data-set.
+# It is strongly recommended to use one of the types and data-sets pre-defined
+# in the types.db file.
 my $dataset =
 [
        {
@@ -70,7 +75,8 @@ sub my_read
 
        # dispatch the values to collectd which passes them on to all registered
        # write functions - the first argument is used to lookup the data set
-       # definition
+       # definition (it is strongly recommended to use a type defined in the
+       # types.db file)
        plugin_dispatch_values ('myplugin', $vl);
 
        # A false return value indicates an error and the plugin will be skipped
index cdd537a..240c6c3 100644 (file)
@@ -59,6 +59,12 @@ static data_source_t dsrc[1] =
  * - name of the data set
  * - number of data sources
  * - list of data sources
+ *
+ * NOTE: If you're defining a custom data-set, you have to make that known to
+ * any servers as well. Else, the server is not able to store values using the
+ * type defined by that data-set.
+ * It is strongly recommended to use one of the types and data-sets
+ * pre-defined in the types.db file.
  */
 static data_set_t ds =
 {
@@ -99,7 +105,8 @@ static int my_read (void)
 
        /* dispatch the values to collectd which passes them on to all registered
         * write functions - the first argument is used to lookup the data set
-        * definition */
+        * definition (it is strongly recommended to use a type defined in the
+        * types.db file) */
        plugin_dispatch_values ("myplugin", &vl);
 
        /* A return value != 0 indicates an error and the plugin will be skipped
index 7667f24..c6bf8ad 100644 (file)
@@ -198,9 +198,9 @@ static void submit_counter (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, "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)
@@ -221,9 +221,9 @@ static void submit_gauge (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, "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)
index fb48109..227c703 100644 (file)
@@ -372,9 +372,9 @@ static void apc_submit_generic (char *type, char *type_inst, double value)
        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));
        sstrncpy (vl.type, type, sizeof (vl.type));
        sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
 
index ee0bf8c..6296335 100644 (file)
@@ -88,9 +88,9 @@ static void as_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, "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));
 
@@ -193,17 +193,17 @@ static int as_read (void)
                if (strcmp (type, "temperature") == 0)
                {
                        value_double = ((double) value_int) / 65536.0;
-                       strcpy (type, "temperature");
+                       sstrncpy (type, "temperature", sizeof (type));
                }
                else if (strcmp (type, "temp") == 0)
                {
                        value_double = ((double) value_int) / 10.0;
-                       strcpy (type, "temperature");
+                       sstrncpy (type, "temperature", sizeof (type));
                }
                else if (strcmp (type, "fanspeed") == 0)
                {
                        value_double = ((double) value_int) / 65536.0;
-                       strcpy (type, "fanspeed");
+                       sstrncpy (type, "fanspeed", sizeof (type));
                }
                else if (strcmp (type, "voltage") == 0)
                {
@@ -213,7 +213,7 @@ static int as_read (void)
                else if (strcmp (type, "adc") == 0)
                {
                        value_double = ((double) value_int) / 10.0;
-                       strcpy (type, "fanspeed");
+                       sstrncpy (type, "fanspeed", sizeof (type));
                }
                else
                {
index c443d38..2ad641d 100644 (file)
@@ -127,8 +127,8 @@ static int ascent_submit_gauge (const char *plugin_instance, /* {{{ */
   vl.values = values;
   vl.values_len = 1;
   vl.time = time (NULL);
-  strcpy (vl.host, hostname_g);
-  strcpy (vl.plugin, "ascent");
+  sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+  sstrncpy (vl.plugin, "ascent", sizeof (vl.plugin));
 
   if (plugin_instance != NULL)
     sstrncpy (vl.plugin_instance, plugin_instance,
index 74b3344..9f1bee6 100644 (file)
@@ -99,8 +99,8 @@ static void battery_submit (const char *plugin_instance, const char *type, doubl
        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));
 
index f73ac99..7c36643 100644 (file)
@@ -124,7 +124,7 @@ FQDNLookup   true
 
 #<Plugin exec>
 #      Exec "user:group" "/path/to/exec"
-#      NotificationExec "/path/to/exec"
+#      NotificationExec "user:group" "/path/to/exec"
 #</Plugin>
 
 @BUILD_PLUGIN_HDDTEMP_TRUE@<Plugin hddtemp>
index 0df763e..5912fe6 100644 (file)
 # define __attribute__(x) /**/
 #endif
 
+#if __GNUC__
+# pragma GCC poison strcpy strcat sprintf strtok
+#endif
+
 extern char hostname_g[];
 extern int  interval_g;
 
index bdab108..fd7c199 100644 (file)
@@ -83,12 +83,12 @@ char *sstrdup (const char *s)
 
        if((r = strdup (s)) == NULL)
        {
-               DEBUG ("Not enough memory.");
-               exit(3);
+               ERROR ("Not enough memory.");
+               exit (3);
        }
 
        return (r);
-}
+} /* char *sstrdup */
 
 /* Even though Posix requires "strerror_r" to return an "int",
  * some systems (e.g. the GNU libc) return a "char *" _and_
@@ -143,12 +143,12 @@ void *smalloc (size_t size)
 
        if ((r = malloc (size)) == NULL)
        {
-               DEBUG("Not enough memory.");
-               exit(3);
+               ERROR ("Not enough memory.");
+               exit (3);
        }
 
-       return r;
-}
+       return (r);
+} /* void *smalloc */
 
 #if 0
 void sfree (void **ptr)
@@ -236,7 +236,7 @@ int strsplit (char *string, char **fields, size_t size)
        i = 0;
        ptr = string;
        saveptr = NULL;
-       while ((fields[i] = strtok_r (ptr, " \t", &saveptr)) != NULL)
+       while ((fields[i] = strtok_r (ptr, " \t\r\n", &saveptr)) != NULL)
        {
                ptr = NULL;
                i++;
index 7773dc4..e9ab783 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -180,11 +180,11 @@ static void submit (int cpu_num, const char *type_instance, counter_t value)
        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));
        ssnprintf (vl.plugin_instance, sizeof (vl.type_instance),
                        "%i", cpu_num);
-       strcpy (vl.type, "cpu");
+       sstrncpy (vl.type, "cpu", sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
        plugin_dispatch_values (&vl);
index f4424e6..3738b54 100644 (file)
@@ -68,9 +68,9 @@ static void cpufreq_submit (int cpu_num, double value)
        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));
+       sstrncpy (vl.type, "cpufreq", sizeof (vl.type));
        ssnprintf (vl.type_instance, sizeof (vl.type_instance),
                        "%i", cpu_num);
 
index 284472b..26d2382 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -125,10 +125,10 @@ 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));
+       sstrncpy (vl.type, "df", sizeof (vl.host));
        sstrncpy (vl.type_instance, df_name, sizeof (vl.type_instance));
 
        plugin_dispatch_values (&vl);
index a6f850a..29aa979 100644 (file)
@@ -213,8 +213,8 @@ static void disk_submit (const char *plugin_instance,
        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));
        sstrncpy (vl.plugin_instance, plugin_instance,
                        sizeof (vl.plugin_instance));
        sstrncpy (vl.type, type, sizeof (vl.type));
index c315eab..c04169f 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -299,8 +299,8 @@ static void submit_counter (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, "dns");
+       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+       sstrncpy (vl.plugin, "dns", sizeof (vl.plugin));
        sstrncpy (vl.type, type, sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
@@ -318,9 +318,9 @@ static void submit_octets (counter_t queries, counter_t responses)
        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 (&vl);
 } /* void submit_counter */
index fbdc785..e208f13 100644 (file)
@@ -243,7 +243,6 @@ static void type_list_incr (type_list_t *list, char *name, int incr)
 static void *collect (void *arg)
 {
        collector_t *this = (collector_t *)arg;
-       pthread_t    self = pthread_self ();
 
        while (1) {
                int loop = 1;
@@ -269,8 +268,8 @@ static void *collect (void *arg)
                 * thread and connection management */
                this->socket = connection->socket;
 
-               log_debug ("[thread #%5lu] handling connection on fd #%i",
-                               self, fileno (this->socket));
+               log_debug ("collect: handling connection on fd #%i",
+                               fileno (this->socket));
 
                while (loop) {
                        /* 256 bytes ought to be enough for anybody ;-) */
@@ -283,8 +282,8 @@ static void *collect (void *arg)
 
                                if (0 != errno) {
                                        char errbuf[1024];
-                                       log_err ("[thread #%5lu] reading from socket (fd #%i) "
-                                                       "failed: %s", self, fileno (this->socket),
+                                       log_err ("collect: reading from socket (fd #%i) "
+                                                       "failed: %s", fileno (this->socket),
                                                        sstrerror (errno, errbuf, sizeof (errbuf)));
                                }
                                break;
@@ -292,9 +291,8 @@ static void *collect (void *arg)
 
                        len = strlen (line);
                        if (('\n' != line[len - 1]) && ('\r' != line[len - 1])) {
-                               log_warn ("[thread #%5lu] line too long (> %zu characters): "
-                                               "'%s' (truncated)",
-                                               (unsigned long) self, sizeof (line) - 1, line);
+                               log_warn ("collect: line too long (> %zu characters): "
+                                               "'%s' (truncated)", sizeof (line) - 1, line);
 
                                while (NULL != fgets (line, sizeof (line), this->socket))
                                        if (('\n' == line[len - 1]) || ('\r' == line[len - 1]))
@@ -304,11 +302,10 @@ static void *collect (void *arg)
 
                        line[len - 1] = '\0';
 
-                       log_debug ("[thread #%5lu] line = '%s'", self, line);
+                       log_debug ("collect: line = '%s'", line);
 
                        if (':' != line[1]) {
-                               log_err ("[thread #%5lu] syntax error in line '%s'",
-                                               self, line);
+                               log_err ("collect: syntax error in line '%s'", line);
                                continue;
                        }
 
@@ -319,8 +316,7 @@ static void *collect (void *arg)
                                int  bytes = 0;
 
                                if (NULL == tmp) {
-                                       log_err ("[thread #%5lu] syntax error in line '%s'",
-                                                       self, line);
+                                       log_err ("collect: syntax error in line '%s'", line);
                                        continue;
                                }
 
@@ -354,7 +350,7 @@ static void *collect (void *arg)
                                } while (NULL != (type = strtok_r (NULL, ",", &ptr)));
                        }
                        else {
-                               log_err ("[thread #%5lu] unknown type '%c'", self, line[0]);
+                               log_err ("collect: unknown type '%c'", line[0]);
                        }
                } /* while (loop) */
 
@@ -394,9 +390,7 @@ static void *open_connection (void *arg)
        }
 
        addr.sun_family = AF_UNIX;
-
        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,8 +651,8 @@ static void email_submit (const char *type, const char *type_instance, gauge_t v
        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));
        sstrncpy (vl.type, type, sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
index 85d41cf..2e20a67 100644 (file)
@@ -39,11 +39,9 @@ static void entropy_submit (double entropy)
        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.type, "entropy", sizeof (vl.type));
 
        plugin_dispatch_values (&vl);
 }
index a9c0941..9f4a725 100644 (file)
@@ -448,9 +448,9 @@ static void hddtemp_submit (char *type_instance, double value)
        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));
+       sstrncpy (vl.type, "temperature", sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
        plugin_dispatch_values (&vl);
index ff4a0aa..806a336 100644 (file)
@@ -197,8 +197,8 @@ static void if_submit (const char *dev, const char *type,
        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));
        sstrncpy (vl.type, type, sizeof (vl.type));
        sstrncpy (vl.type_instance, dev, sizeof (vl.type_instance));
 
index dc69f6b..4d15c6e 100644 (file)
@@ -219,8 +219,8 @@ static int submit_match (const struct ipt_entry_match *match,
     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 = ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
            "%s-%s", chain->table, chain->chain);
@@ -241,11 +241,11 @@ static int submit_match (const struct ipt_entry_match *match,
                    sizeof (vl.type_instance));
     }
 
-    strcpy (vl.type, "ipt_bytes");
+    sstrncpy (vl.type, "ipt_bytes", sizeof (vl.type));
     values[0].counter = (counter_t) entry->counters.bcnt;
     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 (&vl);
 
index a64e7b7..10c4d15 100644 (file)
@@ -238,10 +238,10 @@ static void cipvs_submit_connections (char *pi, char *ti, counter_t value)
        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, "connections", sizeof (vl.type));
        sstrncpy (vl.type_instance, (NULL != ti) ? ti : "total",
                sizeof (vl.type_instance));
 
@@ -264,8 +264,8 @@ static void cipvs_submit_if (char *pi, char *t, char *ti,
        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, t, sizeof (vl.type));
        sstrncpy (vl.type_instance, (NULL != ti) ? ti : "total",
index 792ac34..9b7e618 100644 (file)
--- a/src/irq.c
+++ b/src/irq.c
@@ -132,9 +132,9 @@ static void irq_submit (unsigned int irq, counter_t value)
        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 = ssnprintf (vl.type_instance, sizeof (vl.type_instance),
                        "%u", irq);
index 370e794..5acff29 100644 (file)
@@ -666,7 +666,7 @@ init_value_list (value_list_t *vl, time_t t, virDomainPtr dom)
         n = DATA_MAX_NAME_LEN - strlen (vl->host) - 2;
 
         if (i > 0 && n >= 1) {
-            strcat (vl->host, ":");
+            strncat (vl->host, ":", 1);
             n--;
         }
 
index 7d11b98..72c7756 100644 (file)
@@ -51,9 +51,9 @@ static void load_submit (gauge_t snum, gauge_t mnum, gauge_t lnum)
        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 (&vl);
 }
index 923118f..344cadd 100644 (file)
@@ -228,8 +228,8 @@ static void mbmon_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, "mbmon");
+       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+       sstrncpy (vl.plugin, "mbmon", sizeof (vl.plugin));
        sstrncpy (vl.type, type, sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
index ca93102..ddea2ea 100644 (file)
@@ -223,8 +223,8 @@ static void submit_counter (const char *type, const char *type_inst,
        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)
                sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
@@ -245,8 +245,8 @@ static void submit_counter2 (const char *type, const char *type_inst,
        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)
                sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
@@ -266,8 +266,8 @@ static void submit_gauge (const char *type, const char *type_inst,
        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)
                sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
@@ -288,8 +288,8 @@ static void submit_gauge2 (const char *type, const char *type_inst,
        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)
                sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
index b56fc5a..c1564c8 100644 (file)
@@ -109,9 +109,9 @@ static void memory_submit (const char *type_instance, gauge_t value)
        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));
+       sstrncpy (vl.type, "memory", sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
        plugin_dispatch_values (&vl);
index e09d9f9..994747f 100644 (file)
@@ -216,9 +216,9 @@ static void multimeter_submit (double value)
        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 (&vl);
 }
index 444acaa..312a819 100644 (file)
@@ -126,8 +126,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 +150,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 +171,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 +189,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 */
index d621da5..c2e4c9b 100644 (file)
@@ -171,8 +171,8 @@ static void submit_one (const char *dev, const char *type,
   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));
   sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
   sstrncpy (vl.type, type, sizeof (vl.type));
 
@@ -195,8 +195,8 @@ static void submit_two (const char *dev, const char *type,
   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));
   sstrncpy (vl.plugin_instance, dev, sizeof (vl.plugin_instance));
   sstrncpy (vl.type, type, sizeof (vl.type));
 
index b6778fa..39069aa 100644 (file)
@@ -1403,7 +1403,7 @@ static int add_to_buffer (char *buffer, int buffer_size,
                if (write_part_string (&buffer, &buffer_size, TYPE_HOST,
                                        vl->host, strlen (vl->host)) != 0)
                        return (-1);
-               strcpy (vl_def->host, vl->host);
+               sstrncpy (vl_def->host, vl->host, sizeof (vl_def->host));
        }
 
        if (vl_def->time != vl->time)
@@ -1427,7 +1427,7 @@ static int add_to_buffer (char *buffer, int buffer_size,
                if (write_part_string (&buffer, &buffer_size, TYPE_PLUGIN,
                                        vl->plugin, strlen (vl->plugin)) != 0)
                        return (-1);
-               strcpy (vl_def->plugin, vl->plugin);
+               sstrncpy (vl_def->plugin, vl->plugin, sizeof (vl_def->plugin));
        }
 
        if (strcmp (vl_def->plugin_instance, vl->plugin_instance) != 0)
@@ -1436,7 +1436,7 @@ static int add_to_buffer (char *buffer, int buffer_size,
                                        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, vl->type) != 0)
@@ -1444,7 +1444,7 @@ static int add_to_buffer (char *buffer, int buffer_size,
                if (write_part_string (&buffer, &buffer_size, TYPE_TYPE,
                                        vl->type, strlen (vl->type)) != 0)
                        return (-1);
-               strcpy (type_def, vl->type);
+               sstrncpy (type_def, vl->type, sizeof (type_def));
        }
 
        if (strcmp (vl_def->type_instance, vl->type_instance) != 0)
@@ -1453,7 +1453,7 @@ static int add_to_buffer (char *buffer, int buffer_size,
                                        vl->type_instance,
                                        strlen (vl->type_instance)) != 0)
                        return (-1);
-               strcpy (vl_def->type_instance, vl->type_instance);
+               sstrncpy (vl_def->type_instance, vl->type_instance, sizeof (vl_def->type_instance));
        }
        
        if (write_part_values (&buffer, &buffer_size, ds, vl) != 0)
index 34f01f4..f2db895 100644 (file)
--- a/src/nfs.c
+++ b/src/nfs.c
@@ -188,11 +188,11 @@ static void nfs_procedures_submit (const char *plugin_instance,
        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));
        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++)
        {
index 4de59f3..91bcf75 100644 (file)
@@ -178,9 +178,9 @@ static void submit (char *type, char *inst, long long value)
   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)
@@ -196,6 +196,7 @@ static int nginx_read (void)
   char *ptr;
   char *lines[16];
   int   lines_num = 0;
+  char *saveptr;
 
   char *fields[16];
   int   fields_num;
@@ -213,7 +214,8 @@ static int nginx_read (void)
   }
 
   ptr = nginx_buffer;
-  while ((lines[lines_num] = strtok (ptr, "\n\r")) != NULL)
+  saveptr = NULL;
+  while ((lines[lines_num] = strtok_r (ptr, "\n\r", &saveptr)) != NULL)
   {
     ptr = NULL;
     lines_num++;
index 9475ac9..22bbc5d 100644 (file)
@@ -301,9 +301,9 @@ static void ntpd_submit (char *type, char *type_inst, double value)
        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));
        sstrncpy (vl.type, type, sizeof (vl.type));
        sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
 
index 75504d4..8796d58 100644 (file)
--- a/src/nut.c
+++ b/src/nut.c
@@ -129,7 +129,7 @@ static void nut_submit (nut_ups_t *ups, const char *type,
       ? hostname_g
       : ups->hostname,
       sizeof (vl.host));
-  strcpy (vl.plugin, "nut");
+  sstrncpy (vl.plugin, "nut", sizeof (vl.plugin));
   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));
index 3a56da6..541826f 100644 (file)
@@ -567,7 +567,7 @@ static int pplugin_dispatch_values (pTHX_ HV *values)
                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)))
index 20388c3..ac5b0f8 100644 (file)
@@ -186,11 +186,11 @@ static void ping_submit (char *host, double latency)
        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));
        sstrncpy (vl.type_instance, host, sizeof (vl.type_instance));
+       sstrncpy (vl.type, "ping", sizeof (vl.type));
 
        plugin_dispatch_values (&vl);
 }
index 4a25aaa..bf8fb08 100644 (file)
@@ -584,22 +584,15 @@ void plugin_init_all (void)
        llentry_t *le;
        int status;
 
-       /* Start read-threads */
-       if (list_read != NULL)
-       {
-               const char *rt;
-               int num;
-               rt = global_option_get ("ReadThreads");
-               num = atoi (rt);
-               start_threads ((num > 0) ? num : 5);
-       }
-
        /* Init the value cache */
        uc_init ();
 
-       if (list_init == NULL)
+       if ((list_init == NULL) && (list_read == NULL))
                return;
 
+       /* Calling all init callbacks before checking if read callbacks
+        * are available allows the init callbacks to register the read
+        * callback. */
        le = llist_head (list_init);
        while (le != NULL)
        {
@@ -612,12 +605,25 @@ void plugin_init_all (void)
                                        "failed with status %i. "
                                        "Plugin will be unloaded.",
                                        le->key, status);
+                       /* Plugins that register read callbacks from the init
+                        * callback should take care of appropriate error
+                        * handling themselves. */
                        /* FIXME: Unload _all_ functions */
                        plugin_unregister_read (le->key);
                }
 
                le = le->next;
        }
+
+       /* Start read-threads */
+       if (list_read != NULL)
+       {
+               const char *rt;
+               int num;
+               rt = global_option_get ("ReadThreads");
+               num = atoi (rt);
+               start_threads ((num > 0) ? num : 5);
+       }
 } /* void plugin_init_all */
 
 void plugin_read_all (void)
index 9d93f93..b451073 100644 (file)
@@ -619,7 +619,7 @@ static int powerdns_update_recursor_command (list_item_t *li) /* {{{ */
   }
   else
   {
-    strcpy (buffer, "get ");
+    sstrncpy (buffer, "get ", sizeof (buffer));
     status = strjoin (&buffer[4], sizeof (buffer) - strlen ("get "),
        li->fields, li->fields_num,
        /* seperator = */ " ");
index c0d667d..7531a6a 100644 (file)
@@ -524,10 +524,10 @@ static void ps_submit_state (const char *state, double value)
        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));
+       sstrncpy (vl.type, "ps_state", sizeof (vl.type));
        sstrncpy (vl.type_instance, state, sizeof (vl.type_instance));
 
        plugin_dispatch_values (&vl);
@@ -542,28 +542,28 @@ static void ps_submit_proc_list (procstat_t *ps)
        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));
        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 (&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 (&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 (&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;
index fd499fd..7cf2436 100644 (file)
@@ -291,12 +291,16 @@ static int ds_get (char ***ret, const data_set_t *ds, const value_list_t *vl)
                }
 
                if (isnan (d->min))
-                       strcpy (min, "U");
+               {
+                       sstrncpy (min, "U", sizeof (min));
+               }
                else
                        ssnprintf (min, sizeof (min), "%lf", d->min);
 
                if (isnan (d->max))
-                       strcpy (max, "U");
+               {
+                       sstrncpy (max, "U", sizeof (max));
+               }
                else
                        ssnprintf (max, sizeof (max), "%lf", d->max);
 
@@ -339,7 +343,7 @@ static int srrd_create (char *filename, unsigned long pdp_step, time_t last_up,
        optind = 0; /* bug in librrd? */
        rrd_clear_error ();
 
-       status = rrd_create_r (filename, pdp_step, last_up, argc, argv);
+       status = rrd_create_r (filename, pdp_step, last_up, argc, (void *) argv);
 
        if (status != 0)
        {
@@ -358,7 +362,7 @@ static int srrd_update (char *filename, char *template,
        optind = 0; /* bug in librrd? */
        rrd_clear_error ();
 
-       status = rrd_update_r (filename, template, argc, argv);
+       status = rrd_update_r (filename, template, argc, (void *) argv);
 
        if (status != 0)
        {
index 1c5d5a5..1c874e5 100644 (file)
@@ -41,9 +41,9 @@ static void serial_submit (const char *type_instance,
        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));
+       sstrncpy (vl.type, "serial_octets", sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance,
                        sizeof (vl.type_instance));
 
index 75fa880..d19493d 100644 (file)
@@ -907,7 +907,7 @@ static int csnmp_dispatch_table (host_definition_t *host, data_definition_t *dat
   }
 
   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);
@@ -1296,7 +1296,7 @@ static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
   }
 
   sstrncpy (vl.host, host->name, sizeof (vl.host));
-  strcpy (vl.plugin, "snmp");
+  sstrncpy (vl.plugin, "snmp", sizeof (vl.plugin));
   sstrncpy (vl.type, data->type, sizeof (vl.type));
   sstrncpy (vl.type_instance, data->instance.string, sizeof (vl.type_instance));
 
index 4f0a0ba..f9debc1 100644 (file)
@@ -124,9 +124,9 @@ static void swap_submit (const char *type_instance, double value)
        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));
+       sstrncpy (vl.type, "swap", sizeof (vl.type));
        sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));
 
        plugin_dispatch_values (&vl);
index 67750ef..caca537 100644 (file)
@@ -69,8 +69,8 @@ static void tape_submit (const char *plugin_instance,
        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));
        sstrncpy (vl.plugin_instance, plugin_instance,
                        sizeof (vl.plugin_instance));
        sstrncpy (vl.type, type, sizeof (vl.type));
index 4f46e78..655c53e 100644 (file)
@@ -135,9 +135,9 @@ static void conn_submit_port_entry (port_entry_t *pe)
   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))
index 5b12e98..1231075 100644 (file)
@@ -49,9 +49,9 @@ 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 (&vl);
 } /* void users_submit */
index 8fbc8de..9cbba12 100644 (file)
@@ -170,13 +170,13 @@ int handle_putval (FILE *fh, char **fields, int fields_num)
                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) {
index b72cd5c..f2ab337 100644 (file)
@@ -385,7 +385,7 @@ handle_dns(const char *buf, int len,
     if (0 != x)
        return 0;
     if ('\0' == qh.qname[0])
-       strcpy(qh.qname, ".");
+       sstrncpy (qh.qname, ".", sizeof (qh.qname));
     while ((t = strchr(qh.qname, '\n')))
        *t = ' ';
     while ((t = strchr(qh.qname, '\r')))
@@ -705,7 +705,7 @@ const char *qtype_str(int t)
 {
     static char buf[32];
     switch (t) {
-#if (defined (__NAMESER)) && (__NAMESER >= 19991006)
+#if (defined (__NAMESER)) && (__NAMESER >= 19991001)
            case ns_t_a:        return ("A");
            case ns_t_ns:       return ("NS");
            case ns_t_md:       return ("MD");
@@ -747,7 +747,9 @@ const char *qtype_str(int t)
            case ns_t_dname:    return ("DNAME");
            case ns_t_sink:     return ("SINK");
            case ns_t_opt:      return ("OPT");
+# if __NAMESER >= 19991006
            case ns_t_tsig:     return ("TSIG");
+# endif
            case ns_t_ixfr:     return ("IXFR");
            case ns_t_axfr:     return ("AXFR");
            case ns_t_mailb:    return ("MAILB");
index 1e826a1..25f7c70 100644 (file)
@@ -46,8 +46,8 @@ static void submit (const char *plugin_instance, const char *type,
   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));
index 4cc8251..413674b 100644 (file)
@@ -57,10 +57,10 @@ static void traffic_submit (const char *plugin_instance,
        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));
        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 (&vl);
@@ -79,10 +79,10 @@ static void load_submit (const char *plugin_instance,
        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));
        sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
-       strcpy (vl.type, "load");
+       sstrncpy (vl.type, "load", sizeof (vl.type));
 
        plugin_dispatch_values (&vl);
 }
@@ -99,8 +99,8 @@ static void submit_gauge (const char *plugin_instance, const char *type,
        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));
        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));
index a0644fe..21bbcb4 100644 (file)
@@ -56,8 +56,8 @@ static void wireless_submit (const char *plugin_instance, const char *type,
        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));
        sstrncpy (vl.plugin_instance, plugin_instance,
                        sizeof (vl.plugin_instance));
        sstrncpy (vl.type, type, sizeof (vl.type));
index 01c7e0c..09786fc 100644 (file)
@@ -37,8 +37,8 @@ static void cxmms_submit (const char *type, gauge_t value)
        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 (&vl);