X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Flibvirt.c;h=5acff29a578cd609dff2ba7de65bab1e13c4fc3b;hb=5313ade6a32041b9312e7fe38bb6a212a85f9a0b;hp=bd09abfa0103498c55fd791a17458c415ddadd5f;hpb=2354eda94fa44c8bcb8e39b24b117e7937110224;p=collectd.git diff --git a/src/libvirt.c b/src/libvirt.c index bd09abfa..5acff29a 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -634,7 +634,7 @@ ignore_device_match (ignorelist_t *il, const char *domname, const char *devpath) ERROR ("libvirt plugin: malloc failed."); return 0; } - snprintf (name, n, "%s:%s", domname, devpath); + ssnprintf (name, n, "%s:%s", domname, devpath); r = ignorelist_match (il, name); free (name); return r; @@ -652,8 +652,7 @@ init_value_list (value_list_t *vl, time_t t, virDomainPtr dom) vl->time = t; vl->interval = interval_g; - strncpy (vl->plugin, "libvirt", sizeof (vl->plugin)); - vl->plugin[sizeof (vl->plugin) - 1] = '\0'; + sstrncpy (vl->plugin, "libvirt", sizeof (vl->plugin)); vl->host[0] = '\0'; host_ptr = vl->host; @@ -667,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--; } @@ -706,7 +705,7 @@ cpu_submit (unsigned long long cpu_time, vl.values = values; vl.values_len = 1; - strncpy (vl.type, type, sizeof (vl.type)); + sstrncpy (vl.type, type, sizeof (vl.type)); plugin_dispatch_values (&vl); } @@ -725,9 +724,8 @@ vcpu_submit (counter_t cpu_time, vl.values = values; vl.values_len = 1; - strncpy (vl.type, type, sizeof (vl.type)); - snprintf (vl.type_instance, sizeof (vl.type_instance), "%d", vcpu_nr); - vl.type_instance[sizeof (vl.type_instance) - 1] = '\0'; + sstrncpy (vl.type, type, sizeof (vl.type)); + ssnprintf (vl.type_instance, sizeof (vl.type_instance), "%d", vcpu_nr); plugin_dispatch_values (&vl); } @@ -747,9 +745,8 @@ submit_counter2 (const char *type, counter_t v0, counter_t v1, vl.values = values; vl.values_len = 2; - strncpy (vl.type, type, sizeof (vl.type)); - strncpy (vl.type_instance, devname, sizeof (vl.type_instance)); - vl.type_instance[sizeof (vl.type_instance) - 1] = '\0'; + sstrncpy (vl.type, type, sizeof (vl.type)); + sstrncpy (vl.type_instance, devname, sizeof (vl.type_instance)); plugin_dispatch_values (&vl); } /* void submit_counter2 */