From 53cb321b4264f9a14e60d63651b5927f35b9baf0 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 8 Feb 2026 05:34:37 +0100 Subject: [PATCH] drivers/upsdrvctl.c: forkexec(): double-quote the WIN32 argv[0] in commandline [#3294, #3305] Closes: #3305 Signed-off-by: Jim Klimov --- drivers/upsdrvctl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/upsdrvctl.c b/drivers/upsdrvctl.c index 475d4a6d49..8b1ee9a9db 100644 --- a/drivers/upsdrvctl.c +++ b/drivers/upsdrvctl.c @@ -952,8 +952,11 @@ static void forkexec(char *const argv[], const ups_t *ups) /* the command line is made of the driver name followed by args */ if (strstr(argv[0], ups->driver)) { - /* We already know whom to call (got a pointer to needle in the haystack) */ - snprintf(commandline, sizeof(commandline), "%s", argv[0]); + /* We already know whom to call (got a pointer + * to needle in the haystack); that path may + * have spaces ("Program Files") so quoted. + */ + snprintf(commandline, sizeof(commandline), "\"%s\"", argv[0]); } else { /* Hope for the PATH based resolution to work, perhaps the * driver program is located nearby (depends on configure @@ -966,6 +969,7 @@ static void forkexec(char *const argv[], const ups_t *ups) } while (argv[i] != NULL) { + /* TOTHINK: No known toxic spaces to quote here... */ snprintfcat(commandline, sizeof(commandline), " %s", argv[i]); i++; }