X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fntpd.c;h=22bbc5d1810d9ddbd3b9e10fb30602034e965a90;hb=10075e6fe3c384b73c2dd398a1435f8d10e56654;hp=c5dcb8e53ca3489974f5e3052869b57df476c07d;hpb=b49f3f8aca3b42e64427259dfc6c75242d37b91c;p=collectd.git diff --git a/src/ntpd.c b/src/ntpd.c index c5dcb8e5..22bbc5d1 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -269,11 +269,10 @@ static int ntpd_config (const char *key, const char *value) { int port = (int) (atof (value)); if ((port > 0) && (port <= 65535)) - snprintf (ntpd_port, sizeof (ntpd_port), + ssnprintf (ntpd_port, sizeof (ntpd_port), "%i", port); else - strncpy (ntpd_port, value, sizeof (ntpd_port)); - ntpd_port[sizeof (ntpd_port) - 1] = '\0'; + sstrncpy (ntpd_port, value, sizeof (ntpd_port)); } else if (strcasecmp (key, "ReverseLookups") == 0) { @@ -302,12 +301,13 @@ 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, ""); - strncpy (vl.type_instance, type_inst, sizeof (vl.type_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)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* returns `tv0 - tv1' in milliseconds or 0 if `tv1 > tv0' */ @@ -408,7 +408,7 @@ static int ntpd_connect (void) } /* For a description of the arguments see `ntpd_do_query' below. */ -static int ntpd_receive_response (int req_code, int *res_items, int *res_size, +static int ntpd_receive_response (int *res_items, int *res_size, char **res_data, int res_item_size) { int sd; @@ -613,7 +613,7 @@ static int ntpd_receive_response (int req_code, int *res_items, int *res_size, if (pkt_item_len < res_item_size) pkt_padding = res_item_size - pkt_item_len; DEBUG ("res_item_size = %i; pkt_padding = %i;", - res_item_size, pkt_padding); + res_item_size, (int) pkt_padding); /* Extract the sequence number */ pkt_sequence = INFO_SEQ (res.auth_seq); @@ -652,7 +652,7 @@ static int ntpd_receive_response (int req_code, int *res_items, int *res_size, * We start by allocating some more memory. */ DEBUG ("realloc (%p, %i)", (void *) *res_data, - (items_num + pkt_item_num) * res_item_size); + (int) (items_num + pkt_item_num) * res_item_size); items = realloc ((void *) *res_data, (items_num + pkt_item_num) * res_item_size); if (items == NULL) @@ -766,7 +766,7 @@ static int ntpd_do_query (int req_code, int req_items, int req_size, char *req_d if (status != 0) return (status); - status = ntpd_receive_response (req_code, res_items, res_size, res_data, + status = ntpd_receive_response (res_items, res_size, res_data, res_item_size); return (status); } @@ -874,7 +874,7 @@ static int ntpd_read (void) if (refclock_id < refclock_names_num) { - strncpy (peername, refclock_names[refclock_id], + sstrncpy (peername, refclock_names[refclock_id], sizeof (peername)); } else @@ -883,7 +883,7 @@ static int ntpd_read (void) addr_obj.s_addr = ptr->srcadr; addr_str = inet_ntoa (addr_obj); - strncpy (peername, addr_str, sizeof (peername)); + sstrncpy (peername, addr_str, sizeof (peername)); } } else /* Normal network host. */