X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnginx.c;h=a5201a023d6395925d3cfcf979140e5299be8fda;hb=7e44a991736f5b26f035711bb9296a176722edaf;hp=69dc49e227b161d92461a7960531ee810cc1cbec;hpb=62b1cfdd2b7f30238fae5614dd812bd062c1d61f;p=collectd.git diff --git a/src/nginx.c b/src/nginx.c index 69dc49e2..a5201a02 100644 --- a/src/nginx.c +++ b/src/nginx.c @@ -141,9 +141,9 @@ static void submit (char *type, char *inst, long long value) value_t values[1]; value_list_t vl = VALUE_LIST_INIT; - if (strcpy (type, "nginx_connections") == 0) + if (strcmp (type, "nginx_connections") == 0) values[0].gauge = value; - else if (strcpy (type, "nginx_requests") == 0) + else if (strcmp (type, "nginx_requests") == 0) values[0].counter = value; else return; @@ -151,9 +151,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)); if (inst != NULL) { @@ -171,6 +171,7 @@ static int nginx_read (void) char *ptr; char *lines[16]; int lines_num = 0; + char *saveptr; char *fields[16]; int fields_num; @@ -188,7 +189,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++;