From: Michael Snyder <msnyder@redhat.com>
To: Andrew STUBBS <andrew.stubbs@st.com>
Cc: GDB Patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] allow nested sourced commands
Date: Tue, 04 Apr 2006 19:58:00 -0000 [thread overview]
Message-ID: <4432CFC1.4090308@redhat.com> (raw)
In-Reply-To: <44324B1E.3070409@st.com>
Andrew STUBBS wrote:
>>
>>> I have discovered a problem in the GDB command line reading code.
>>>
>>> command_line_input() uses a static buffer to hold the current
>>> command. This means that it is not properly re-entrant - commands
>>> that contain other commands, such as user defined commands, are not
>>> handled safely.
>>
>>
>> See http://sources.redhat.com/ml/gdb-patches/2006-03/msg00356.html
>>
>> The attached patch should fix the problem.
>>
>> I tried to fix the problem in command_line_input, but there were too
>> many ways for the string to leak, so I have opted for the simpler fix,
>> even though it feels like treating the symptoms, not the problem.
>>
>> Anyway, with this patch it no longer attempts to read data that has
>> been overwritten, so everything works fine. Valgrind reports no
>> problems with
>> the test case I posted before.
>>
>> Andrew Stubbs
Well, it has the virtue of simplicity!
At first glance, it seems conceptually valid.
I think you need a clean-up, though. What if it errors?
> ------------------------------------------------------------------------
>
> 2006-04-04 Andrew Stubbs <andrew.stubbs@st.com>
>
> * cli/cli-script.c (struct user_args): Add command field.
> (arg_cleanup): Free command string.
> (setup_user_args): Copy the command line before relying on it.
>
> Index: src/gdb/cli/cli-script.c
> ===================================================================
> --- src.orig/gdb/cli/cli-script.c 2006-04-04 10:53:26.000000000 +0100
> +++ src/gdb/cli/cli-script.c 2006-04-04 11:09:33.000000000 +0100
> @@ -54,6 +54,7 @@ static int control_level;
> struct user_args
> {
> struct user_args *next;
> + char *command;
> struct
> {
> char *arg;
> @@ -483,6 +484,7 @@ arg_cleanup (void *ignore)
> _("arg_cleanup called with no user args.\n"));
>
> user_args = user_args->next;
> + xfree (oargs->command);
> xfree (oargs);
> }
>
> @@ -507,6 +509,8 @@ setup_user_args (char *p)
> if (p == NULL)
> return old_chain;
>
> + user_args->command = p = xstrdup (p);
> +
> while (*p)
> {
> char *start_arg;
next prev parent reply other threads:[~2006-04-04 19:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-30 14:29 command_line_input() not re-entrant Andrew STUBBS
2006-04-04 10:27 ` [PATCH] allow nested sourced commands Andrew STUBBS
2006-04-04 10:34 ` Andrew STUBBS
2006-04-04 19:58 ` Michael Snyder [this message]
2006-04-05 10:05 ` Andrew STUBBS
2006-04-05 18:48 ` Michael Snyder
2006-04-06 9:49 ` Andrew STUBBS
2006-04-06 13:40 ` Daniel Jacobowitz
2006-04-07 11:17 ` Andrew STUBBS
2006-04-07 13:18 ` Daniel Jacobowitz
2006-04-07 13:33 ` Andrew STUBBS
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4432CFC1.4090308@redhat.com \
--to=msnyder@redhat.com \
--cc=andrew.stubbs@st.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox