From 20677c747a6b44bd495a6d656015107ea47fff16 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Jul 18 2024 20:10:50 +0000 Subject: sanlock: terminate helper path and args --- diff --git a/src/lockspace.c b/src/lockspace.c index 7e5185d..a984754 100644 --- a/src/lockspace.c +++ b/src/lockspace.c @@ -82,8 +82,8 @@ static int helper_set_max_sectors_kb(struct sync_disk *disk, uint32_t set_kb) memset(&hm, 0, sizeof(hm)); hm.type = HELPER_MSG_WRITE_SYSFS; - memcpy(hm.path, sysfs_path, SANLK_HELPER_PATH_LEN); - snprintf(hm.args, sizeof(hm.args), "%u", set_kb); + memcpy(hm.path, sysfs_path, SANLK_HELPER_PATH_LEN-1); + snprintf(hm.args, sizeof(hm.args)-1, "%u", set_kb); retry: rv = write(helper_kill_fd, &hm, sizeof(hm)); diff --git a/src/main.c b/src/main.c index 5404554..124848b 100644 --- a/src/main.c +++ b/src/main.c @@ -139,8 +139,8 @@ static void send_helper_kill(struct space *sp, struct client *cl, int sig) if (sig == SIGRUNPATH) { hm.type = HELPER_MSG_RUNPATH; - memcpy(hm.path, cl->killpath, SANLK_HELPER_PATH_LEN); - memcpy(hm.args, cl->killargs, SANLK_HELPER_ARGS_LEN); + memcpy(hm.path, cl->killpath, SANLK_HELPER_PATH_LEN-1); + memcpy(hm.args, cl->killargs, SANLK_HELPER_ARGS_LEN-1); /* only include pid if it's requested as a killpath arg */ if (cl->flags & CL_KILLPATH_PID) diff --git a/src/resource.c b/src/resource.c index af22f10..f5b2f98 100644 --- a/src/resource.c +++ b/src/resource.c @@ -2219,8 +2219,8 @@ static void do_request(struct token *tt, int pid, uint32_t force_mode) } else if (force_mode == SANLK_REQ_GRACEFUL) { if (killpath[0]) { hm.type = HELPER_MSG_RUNPATH; - memcpy(hm.path, killpath, SANLK_HELPER_PATH_LEN); - memcpy(hm.args, killargs, SANLK_HELPER_ARGS_LEN); + memcpy(hm.path, killpath, SANLK_HELPER_PATH_LEN-1); + memcpy(hm.args, killargs, SANLK_HELPER_ARGS_LEN-1); } else { hm.type = HELPER_MSG_KILLPID; hm.pid = pid;