* [PATCH] Don't split executable paths with spaces in into multiple arguments
@ 2009-11-04 13:26 Jon Beniston
2009-11-04 16:17 ` Joel Brobecker
0 siblings, 1 reply; 6+ messages in thread
From: Jon Beniston @ 2009-11-04 13:26 UTC (permalink / raw)
To: gdb-patches
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);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Don't split executable paths with spaces in into multiple arguments
2009-11-04 13:26 [PATCH] Don't split executable paths with spaces in into multiple arguments Jon Beniston
@ 2009-11-04 16:17 ` Joel Brobecker
2009-11-09 17:42 ` Tom Tromey
0 siblings, 1 reply; 6+ messages in thread
From: Joel Brobecker @ 2009-11-04 16:17 UTC (permalink / raw)
To: Jon Beniston; +Cc: gdb-patches
> gdb/
> 2009-11-04 Jon Beniston <jon@beniston.com>
>
> * remote-sim.c(gdbsim_create_inferior) Quote executable path in case
> it
> contains spaces.
OK. This is not handling the case where the filename contains a double
quote, but it is not making things worse, and double-quotes in filenames
are probably extremely rare.
Just a tiny formatting request: Please add a space before
"(gdbsim_create_inferior)" and make sure that each line does not
exceed 80 character.
> - len = strlen (exec_file) + 1 + strlen (args) + 1 + /*slop */ 10;
> + len = 2 + strlen (exec_file) + 1 + strlen (args) + 1 + /*slop */ 10;
This is not your doing, but the remote-sim code is full of "slop" and
"slack", etc, and I wonder how hard it would be to make it crash due
to not enough "slack" :-(.
--
Joel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Don't split executable paths with spaces in into multiple arguments
2009-11-04 16:17 ` Joel Brobecker
@ 2009-11-09 17:42 ` Tom Tromey
2009-11-09 17:46 ` Joel Brobecker
0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2009-11-09 17:42 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Jon Beniston, gdb-patches
>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:
>> gdb/
>> 2009-11-04 Jon Beniston <jon@beniston.com>
>> * remote-sim.c(gdbsim_create_inferior) Quote executable path in case
>> it
>> contains spaces.
Joel> OK. This is not handling the case where the filename contains a double
Joel> quote, but it is not making things worse, and double-quotes in filenames
Joel> are probably extremely rare.
It seems to me that it would not be significantly harder for the code to
do the correct thing in all cases.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Don't split executable paths with spaces in into multiple arguments
2009-11-09 17:42 ` Tom Tromey
@ 2009-11-09 17:46 ` Joel Brobecker
2009-11-09 18:04 ` Tom Tromey
0 siblings, 1 reply; 6+ messages in thread
From: Joel Brobecker @ 2009-11-09 17:46 UTC (permalink / raw)
To: Tom Tromey; +Cc: Jon Beniston, gdb-patches
> It seems to me that it would not be significantly harder for the code to
> do the correct thing in all cases.
To be honest, I didn't even think about it, mostly because I thought
that the issue would be so rare that it was possibly just retorical.
So I felt that I shouldn't insist that we do the right thing in all
cases. Too lax?
--
Joel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Don't split executable paths with spaces in into multiple arguments
2009-11-09 17:46 ` Joel Brobecker
@ 2009-11-09 18:04 ` Tom Tromey
2009-11-09 21:11 ` Joel Brobecker
0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2009-11-09 18:04 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Jon Beniston, gdb-patches
>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:
>> It seems to me that it would not be significantly harder for the code to
>> do the correct thing in all cases.
Joel> To be honest, I didn't even think about it, mostly because I thought
Joel> that the issue would be so rare that it was possibly just retorical.
Joel> So I felt that I shouldn't insist that we do the right thing in all
Joel> cases. Too lax?
Ordinarily my view is "forward biased": an improvement is an
improvement, and requiring perfection tends to raise the patch
submission bar too high.
In this particular case, though, I would probably have pushed back a
bit, first because the patch is already fixing a previous "can't happen"
assumption, and second because the correct code is really just 4 or 5
lines. (I thought for sure we would already have the quoting code lying
around, but I grepped a little and couldn't find it. It is odd that we
have buildargv to split the argv but nothing to quote it.)
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Don't split executable paths with spaces in into multiple arguments
2009-11-09 18:04 ` Tom Tromey
@ 2009-11-09 21:11 ` Joel Brobecker
0 siblings, 0 replies; 6+ messages in thread
From: Joel Brobecker @ 2009-11-09 21:11 UTC (permalink / raw)
To: Tom Tromey; +Cc: Jon Beniston, gdb-patches
> In this particular case, though, I would probably have pushed back a
> bit, first because the patch is already fixing a previous "can't happen"
> assumption, and second because the correct code is really just 4 or 5
> lines. (I thought for sure we would already have the quoting code lying
> around, but I grepped a little and couldn't find it. It is odd that we
> have buildargv to split the argv but nothing to quote it.)
I understand.
Jon,
Would you mind enhancing your patch to handle all cases properly,
please?
Thanks,
--
Joel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-11-09 21:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-04 13:26 [PATCH] Don't split executable paths with spaces in into multiple arguments Jon Beniston
2009-11-04 16:17 ` Joel Brobecker
2009-11-09 17:42 ` Tom Tromey
2009-11-09 17:46 ` Joel Brobecker
2009-11-09 18:04 ` Tom Tromey
2009-11-09 21:11 ` Joel Brobecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox