Skip to content

Commit 8111ced

Browse files
authored
Merge pull request #3307 from jimklimov/issue-3205
drivers/upsdrvctl.c: forkexec(): double-quote the WIN32 argv[0] in commandline
2 parents aa4e727 + 53cb321 commit 8111ced

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/upsdrvctl.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,8 +952,11 @@ static void forkexec(char *const argv[], const ups_t *ups)
952952

953953
/* the command line is made of the driver name followed by args */
954954
if (strstr(argv[0], ups->driver)) {
955-
/* We already know whom to call (got a pointer to needle in the haystack) */
956-
snprintf(commandline, sizeof(commandline), "%s", argv[0]);
955+
/* We already know whom to call (got a pointer
956+
* to needle in the haystack); that path may
957+
* have spaces ("Program Files") so quoted.
958+
*/
959+
snprintf(commandline, sizeof(commandline), "\"%s\"", argv[0]);
957960
} else {
958961
/* Hope for the PATH based resolution to work, perhaps the
959962
* driver program is located nearby (depends on configure
@@ -966,6 +969,7 @@ static void forkexec(char *const argv[], const ups_t *ups)
966969
}
967970

968971
while (argv[i] != NULL) {
972+
/* TOTHINK: No known toxic spaces to quote here... */
969973
snprintfcat(commandline, sizeof(commandline), " %s", argv[i]);
970974
i++;
971975
}

0 commit comments

Comments
 (0)