Module: check_mk
Branch: master
Commit: d9922d6cdca367a4e4e0ad5da1bc80e5288edfb9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d9922d6cdca367…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jan 7 21:11:08 2011 +0100
Livestatus: fix the fix: pnpgraph detection
the patch recently applied that replace strcat with strncat
was broken and damaged the pnp path detection. I have done
and alternative implemention.
---
livestatus/src/pnp4nagios.cc | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/livestatus/src/pnp4nagios.cc b/livestatus/src/pnp4nagios.cc
index 20fd289..e8e72eb 100644
--- a/livestatus/src/pnp4nagios.cc
+++ b/livestatus/src/pnp4nagios.cc
@@ -44,19 +44,25 @@ int pnpgraph_present(char *host, char *service)
return -1;
char path[4096];
- strncpy(path, g_pnp_path, sizeof(path) - 1);
+ int needed_size = strlen(g_pnp_path) + strlen(host) + 16;
+ if (service)
+ needed_size += strlen(service);
+ if (needed_size > sizeof(path))
+ return -1;
+
+ strcpy(path, g_pnp_path);
char *end = path + strlen(path);
- strncpy(end, host, sizeof(end) - 1);
+ strcpy(end, host);
cleanup_pnpname(end);
- strncat(end, "/", sizeof(end) - strlen(end) - 1);
+ strcat(end, "/");
end = end + strlen(end);
if (service) {
- strncat(end, service, sizeof(end) - strlen(end) - 1);
+ strcat(end, service);
cleanup_pnpname(end);
strcat(end, ".xml");
}
else
- strncat(end, "_HOST_.xml", sizeof(end) - strlen(end) - 1);
+ strcat(end, "_HOST_.xml");
if (0 == access(path, R_OK))
return 1;