X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fnginx.c;h=ea5c126318f05acdb4784ee9856ab8b5061003aa;hb=2928de22ab136c8b07e1204db4128dc1aeeaff01;hp=283e8f6f3fa85ae2568aab63c45a170ed8ba35ca;hpb=714644fb443eb2dc8fd8c683cae171caef40cf7a;p=collectd.git diff --git a/src/nginx.c b/src/nginx.c index 283e8f6f..ea5c1263 100644 --- a/src/nginx.c +++ b/src/nginx.c @@ -1,6 +1,7 @@ /** * collectd - src/nginx.c * Copyright (C) 2006,2007 Florian octo Forster + * Copyright (C) 2008 Sebastian Harl * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -18,6 +19,7 @@ * * Authors: * Florian octo Forster + * Sebastian Harl **/ #include "collectd.h" @@ -122,7 +124,8 @@ static int init (void) if (user != NULL) { - if (snprintf (credentials, 1024, "%s:%s", user, pass == NULL ? "" : pass) >= 1024) + if (ssnprintf (credentials, sizeof (credentials), + "%s:%s", user, pass == NULL ? "" : pass) >= sizeof (credentials)) { ERROR ("nginx plugin: Credentials would have been truncated."); return (-1); @@ -180,14 +183,12 @@ static void submit (char *type, char *inst, long long value) 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) - { - strncpy (vl.type_instance, inst, sizeof (vl.type_instance)); - vl.type_instance[sizeof (vl.type_instance) - 1] = '\0'; - } + sstrncpy (vl.type_instance, inst, sizeof (vl.type_instance)); - plugin_dispatch_values (type, &vl); + plugin_dispatch_values (&vl); } /* void submit */ static int nginx_read (void)