This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Don't split executable paths with spaces in into multiple arguments


Hi,

The following patch prevents executable paths with spaces in them from being
passed to the simulator as multiple arguments.

OK to apply?

Cheers,
Jon

gdb/
2009-11-04  Jon Beniston  <jon@beniston.com>

	* remote-sim.c(gdbsim_create_inferior) Quote executable path in case
it
	contains spaces.

===================================================================
--- remote-sim.c        (revision 41)
+++ remote-sim.c        (working copy)
@@ -458,10 +458,13 @@

   if (exec_file != NULL)
     {
-      len = strlen (exec_file) + 1 + strlen (args) + 1 + /*slop */ 10;
+      len = 2 + strlen (exec_file) + 1 + strlen (args) + 1 + /*slop */ 10;
       arg_buf = (char *) alloca (len);
       arg_buf[0] = '\0';
+      /* Add quotes around exec_file in case there are spaces in the path.
*/
+      strcat (arg_buf, "\"");
       strcat (arg_buf, exec_file);
+      strcat (arg_buf, "\"");
       strcat (arg_buf, " ");
       strcat (arg_buf, args);
       argv = buildargv (arg_buf);




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]