From: Michael Snyder <msnyder@vmware.com>
To: Thiago Jung Bauermann <bauerman@br.ibm.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [RFA] Resubmit reverse debugging [5/5]
Date: Wed, 08 Oct 2008 21:06:00 -0000 [thread overview]
Message-ID: <48ED201F.6040905@vmware.com> (raw)
In-Reply-To: <1223489663.19088.43.camel@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 766 bytes --]
Thiago Jung Bauermann wrote:
> El mar, 07-10-2008 a las 19:20 -0700, Michael Snyder escribió:
>> +static void
>> +exec_reverse_once (char *cmd, char *args, int from_tty)
>> +{
>> + /* String buffer for command consing. */
>> + char reverse_command[512];
> <snip>
>> + sprintf (reverse_command, "%s %s", cmd, args ? args : "");
>> +
>> + execution_direction = EXEC_REVERSE;
>> + execute_command (reverse_command, from_tty);
>> + do_cleanups (old_chain);
>
> That fixed-length buffer being written with sprintf doesn't look good...
> What do you think about using xstrprintf instead? That will remove the
> possibility of buffer overflow, and also remove an arbitrary limit.
How about this? (the function pointer idea I leave for a future
enhancement):
[-- Attachment #2: xstrprintf.txt --]
[-- Type: text/plain, Size: 1122 bytes --]
Index: reverse.c
===================================================================
RCS file: /cvs/src/src/gdb/Attic/reverse.c,v
retrieving revision 1.1.10.6
diff -u -p -r1.1.10.6 reverse.c
--- reverse.c 8 Oct 2008 00:26:28 -0000 1.1.10.6
+++ reverse.c 8 Oct 2008 21:03:59 -0000
@@ -44,8 +44,7 @@ static void exec_direction_default (void
static void
exec_reverse_once (char *cmd, char *args, int from_tty)
{
- /* String buffer for command consing. */
- char reverse_command[512];
+ char *reverse_command;
enum exec_direction_kind dir = execution_direction;
struct cleanup *old_chain;
@@ -59,9 +58,9 @@ exec_reverse_once (char *cmd, char *args
if (!target_can_execute_reverse)
error (_("Target %s does not support this command."), target_shortname);
+ reverse_command = xstrprintf ("%s %s", cmd, args ? args : "");
old_chain = make_cleanup (exec_direction_default, NULL);
- sprintf (reverse_command, "%s %s", cmd, args ? args : "");
-
+ make_cleanup (xfree, reverse_command);
execution_direction = EXEC_REVERSE;
execute_command (reverse_command, from_tty);
do_cleanups (old_chain);
next prev parent reply other threads:[~2008-10-08 21:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-08 2:23 Michael Snyder
2008-10-08 18:15 ` Thiago Jung Bauermann
2008-10-08 19:16 ` Eli Zaretskii
2008-10-09 4:23 ` Pedro Alves
2008-10-09 8:41 ` Eli Zaretskii
2008-10-08 20:14 ` Thiago Jung Bauermann
2008-10-08 20:55 ` Michael Snyder
2008-10-08 20:27 ` Michael Snyder
2008-10-08 20:43 ` Thiago Jung Bauermann
2008-12-15 12:29 ` Tomas Holmberg
2008-10-08 21:06 ` Michael Snyder [this message]
2008-10-08 21:14 ` Thiago Jung Bauermann
2008-10-17 19:48 ` Michael Snyder
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=48ED201F.6040905@vmware.com \
--to=msnyder@vmware.com \
--cc=bauerman@br.ibm.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