X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnginx.c;h=91bcf75404927bfcd708e16faf71b5b7606fe304;hb=a94f5335f7b6a6e6672b84adb00f576b83d46b58;hp=4de59f3752b8827f28bf8885ec2f3c9073dd6c5d;hpb=bab707fe46b2ef69f391864f3bb08b4dca19634e;p=collectd.git diff --git a/src/nginx.c b/src/nginx.c index 4de59f37..91bcf754 100644 --- a/src/nginx.c +++ b/src/nginx.c @@ -178,9 +178,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)); sstrncpy (vl.type, type, sizeof (vl.type)); if (inst != NULL) @@ -196,6 +196,7 @@ static int nginx_read (void) char *ptr; char *lines[16]; int lines_num = 0; + char *saveptr; char *fields[16]; int fields_num; @@ -213,7 +214,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++;