X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fapcups.c;h=ca026b9689907f49f7227c3ae612b54e4ff4cfef;hb=e628f39838a67b40d52dfb8425b4d8474fbd0550;hp=462006a66a2a9447738ad60c060c2a3451c6e60f;hpb=23164f56d04219d0dd1b1e4954c3edc0609f0eb8;p=collectd.git diff --git a/src/apcups.c b/src/apcups.c index 462006a6..ca026b96 100644 --- a/src/apcups.c +++ b/src/apcups.c @@ -117,8 +117,7 @@ static int net_open (char *host, int port) assert ((port > 0x00000000) && (port <= 0x0000FFFF)); /* Convert the port to a string */ - snprintf (port_str, 8, "%i", port); - port_str[7] = '\0'; + ssnprintf (port_str, sizeof (port_str), "%i", port); /* Resolve name */ memset ((void *) &ai_hints, '\0', sizeof (ai_hints)); @@ -369,9 +368,10 @@ static void apc_submit_generic (char *type, char *type_inst, double value) 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)