From: Robin Sonefors
strrchr may search from the end of the string, but it still expects the
pointer it is provided to point to the beginning of the string. Thus, we'd
only check if the last byte was a slash, rather than for the last slash.
Manipulating the cmd_name for basename discovery is unnecessary, so
don't.
Signed-off-by: Robin Sonefors
---
base/workers.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/base/workers.c b/base/workers.c
index 0f33a8a..7042724 100644
--- a/base/workers.c
+++ b/base/workers.c
@@ -807,14 +807,12 @@ static worker_process *get_worker(worker_job *job)
cmd_name = job->command;
if ((space = strchr(cmd_name, ' ')) != NULL) {
*space = '\0';
- slash = strrchr(space - 1, '/');
+ slash = strrchr(cmd_name, '/');
}
wp_list = dkhash_get(specialized_workers, cmd_name, NULL);
if (!wp_list && slash) {
- *slash = 0;
- wp_list = dkhash_get(specialized_workers, slash + 1, NULL);
- *(slash++) = '/';
+ wp_list = dkhash_get(specialized_workers, ++slash, NULL);
}
if (wp_list != NULL) {
logit(NSLOG_INFO_MESSAGE, 1, "Found specialized worker(s) for '%s'", (slash && *slash != '/') ? slash : cmd_name);
--
1.7.11.7
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]