From f8a989439b6e280b394d7465c0429d04f83faf72 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 25 Feb 2021 17:18:03 +0100 Subject: [PATCH] Minor, insert '/' only if pasting components require it Signed-off-by: Joachim Wiberg --- plugins/pidfile.c | 4 ++-- src/exec.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/pidfile.c b/plugins/pidfile.c index 4377d736..c7f20458 100644 --- a/plugins/pidfile.c +++ b/plugins/pidfile.c @@ -68,7 +68,7 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask) svc_t *svc; _d("Got dir: %s, name: %s, mask: %08x", dir, name, mask); - snprintf(fn, sizeof(fn), "%s/%s", dir, name); + snprintf(fn, sizeof(fn), "%s%s%s", dir, fisslashdir(dir) ? "" : "/", name); if (fnmatch("*\\.pid", fn, 0) && fnmatch("*/pid", fn, 0)) return; @@ -131,7 +131,7 @@ static void pidfile_handle_dir(struct iwatch *iw, char *dir, char *name, int mas char path[strlen(dir) + strlen(name) + 2]; struct iwatch_path *iwp; - snprintf(path, sizeof(path), "%s/%s", dir, name); + snprintf(path, sizeof(path), "%s%s%s", dir, fisslashdir(dir) ? "" : "/", name); _d("path: %s", path); iwp = iwatch_find_by_path(iw, path); diff --git a/src/exec.c b/src/exec.c index eba38738..874816d5 100644 --- a/src/exec.c +++ b/src/exec.c @@ -454,7 +454,7 @@ int run_parts(char *dir, char *cmd) int status; int exit_status; - snprintf(path, sizeof(path), "%s/%s", dir, name); + snprintf(path, sizeof(path), "%s%s%s", dir, fisslashdir(dir) ? "" : "/", name); if (stat(path, &st)) { _d("Failed stat(%s): %s", path, strerror(errno)); continue;