X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fipvs.c;h=87eee108a79410853b6f02e107697b7a358f465a;hb=66f9d645f883eee0aa408428eefdebdcc6dcfa7e;hp=c5054a8380b7eecfc715d2fb6996a5442bce4e1c;hpb=2354eda94fa44c8bcb8e39b24b117e7937110224;p=collectd.git diff --git a/src/ipvs.c b/src/ipvs.c index c5054a83..87eee108 100644 --- a/src/ipvs.c +++ b/src/ipvs.c @@ -191,7 +191,7 @@ static int get_pi (struct ip_vs_service_entry *se, char *pi, size_t size) /* inet_ntoa() returns a pointer to a statically allocated buffer * I hope non-glibc systems behave the same */ - len = snprintf (pi, size, "%s_%s%u", inet_ntoa (addr), + len = ssnprintf (pi, size, "%s_%s%u", inet_ntoa (addr), (se->protocol == IPPROTO_TCP) ? "TCP" : "UDP", ntohs (se->port)); @@ -215,7 +215,7 @@ static int get_ti (struct ip_vs_dest_entry *de, char *ti, size_t size) /* inet_ntoa() returns a pointer to a statically allocated buffer * I hope non-glibc systems behave the same */ - len = snprintf (ti, size, "%s_%u", inet_ntoa (addr), + len = ssnprintf (ti, size, "%s_%u", inet_ntoa (addr), ntohs (de->port)); if ((0 > len) || (size <= len)) { @@ -235,14 +235,13 @@ static void cipvs_submit_connections (char *pi, char *ti, counter_t value) vl.values = values; vl.values_len = 1; - vl.time = time (NULL); vl.interval = interval_g; - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "ipvs"); - strncpy (vl.plugin_instance, pi, sizeof (vl.plugin_instance)); - strcpy (vl.type, "connections"); - strncpy (vl.type_instance, (NULL != ti) ? ti : "total", + 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, "connections", sizeof (vl.type)); + sstrncpy (vl.type_instance, (NULL != ti) ? ti : "total", sizeof (vl.type_instance)); plugin_dispatch_values (&vl); @@ -261,14 +260,13 @@ static void cipvs_submit_if (char *pi, char *t, char *ti, vl.values = values; vl.values_len = 2; - vl.time = time (NULL); vl.interval = interval_g; - strcpy (vl.host, hostname_g); - strcpy (vl.plugin, "ipvs"); - strncpy (vl.plugin_instance, pi, sizeof (vl.plugin_instance)); - strncpy (vl.type, t, sizeof (vl.type)); - strncpy (vl.type_instance, (NULL != ti) ? ti : "total", + 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", sizeof (vl.type_instance)); plugin_dispatch_values (&vl); @@ -280,7 +278,7 @@ static void cipvs_submit_dest (char *pi, struct ip_vs_dest_entry *de) { char ti[DATA_MAX_NAME_LEN]; - if (0 != get_ti (de, ti, DATA_MAX_NAME_LEN)) + if (0 != get_ti (de, ti, sizeof (ti))) return; cipvs_submit_connections (pi, ti, stats.conns); @@ -298,7 +296,7 @@ static void cipvs_submit_service (struct ip_vs_service_entry *se) int i = 0; - if (0 != get_pi (se, pi, DATA_MAX_NAME_LEN)) + if (0 != get_pi (se, pi, sizeof (pi))) return; cipvs_submit_connections (pi, NULL, stats.conns);