Replace all occurrences of `strcpy' with `sstrncpy'.
[collectd.git] / src / nginx.c
index 69dc49e..a5201a0 100644 (file)
@@ -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++;