[PATCH resend 2/2] winedbg: Quote command line arguments

Robbert van der Helm mail at robbertvanderhelm.nl
Fri Nov 5 09:09:11 CDT 2021


This way the arguments in `winedbg [--gdb] 'foo bar.exe' arg1 'arg 2'` get treated in the same way
as those in `wine 'foo bar.exe' arg1 'arg 2'`. Previously, winedbg would essentially concatenate the
arguments from argv into a single command line without quoting individual arguments. With the
previously mentioned winedbg invocation, this would thus cause `foo` to be run with the argumetns
`bar.exe` `arg1` `arg` and `2`, instead of `foo bar.exe` being run with the expected two arguments.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51844
Signed-off-by: Robbert van der Helm <mail at robbertvanderhelm.nl>
---
This will break existing usages that manually quote their arguments (in the same way as
`build_command_line()` does), but I feel like staying consistent with the way commands line
arguments normally work in Unix-land (and in `gdb --args`) would lead to fewer surprises overall.
---
 programs/winedbg/tgt_active.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c
index ad46d6b5fc5e..ec89039c1bfd 100644
--- a/programs/winedbg/tgt_active.c
+++ b/programs/winedbg/tgt_active.c
@@ -921,28 +921,15 @@ enum dbg_start  dbg_active_attach(int argc, char* argv[])
  */
 enum dbg_start    dbg_active_launch(int argc, char* argv[])
 {
-    int         i, len;
     LPSTR	cmd_line;
 
     if (argc == 0) return start_error_parse;
 
-    if (!(cmd_line = HeapAlloc(GetProcessHeap(), 0, len = 1)))
+    if (!(cmd_line = build_command_line(argv)))
     {
-    oom_leave:
         dbg_printf("Out of memory\n");
         return start_error_init;
     }
-    cmd_line[0] = '\0';
-
-    for (i = 0; i < argc; i++)
-    {
-        len += strlen(argv[i]) + 1;
-        if (!(cmd_line = HeapReAlloc(GetProcessHeap(), 0, cmd_line, len)))
-            goto oom_leave;
-        strcat(cmd_line, argv[i]);
-        cmd_line[len - 2] = ' ';
-        cmd_line[len - 1] = '\0';
-    }
 
     if (!dbg_start_debuggee(cmd_line))
     {
-- 
2.33.1





More information about the wine-devel mailing list