From 52508f77bbca3cf6f31fb6775e1dd399391fad64 Mon Sep 17 00:00:00 2001 From: dmiller Date: Mon, 16 Feb 2026 18:40:19 +0000 Subject: [PATCH] Try to rescue users in one simple case --- ncat/ncat_exec_win.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ncat/ncat_exec_win.c b/ncat/ncat_exec_win.c index 2a7eb63d6..dd76b4f0e 100644 --- a/ncat/ncat_exec_win.c +++ b/ncat/ncat_exec_win.c @@ -191,6 +191,7 @@ static int run_command_redirected(char *cmdexec, struct subprocess_info *info) SECURITY_ATTRIBUTES sa; STARTUPINFO si; PROCESS_INFORMATION pi; + char *app_name = NULL; setup_environment(&info->fdn); @@ -248,7 +249,18 @@ static int run_command_redirected(char *cmdexec, struct subprocess_info *info) memset(&pi, 0, sizeof(pi)); - if (CreateProcess(NULL, cmdexec, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi) == 0) { + /* The user ought to quote the binary name if it contains spaces, but they + * might not. If it's not quoted, we'll try to help them out. */ + if (cmdexec[0] != '"') { + DWORD dwType = 0; + /* Check if the whole command is just the name of an executable file. */ + if (GetBinaryType(cmdexec, &dwType)) { + /* If so, pass this to CreateProcess to avoid space-splitting */ + app_name = cmdexec; + } + } + + if (CreateProcess(app_name, cmdexec, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi) == 0) { if (o.verbose) { LPVOID lpMsgBuf; FormatMessage(