Re: [RFA] Resubmit reverse debugging [5/5]

Thiago Jung Bauermann
2008-10-08T20:14:54Z

El miÃ©, 08-10-2008 a las 15:14 -0300, Thiago Jung Bauermann escribiÃ³:
> 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.

By the way, the string manipulation can be avoided if you pass a
function pointer to exec_reverse_once. Then you can call it passing
next_command, continue_command and all others. It seems cleaner to me,
what do you think?

Also, will there be anything added to reverse.c in the future? If not,
IMHO it's easier just to put these command definitions and setup in
infcmd.c, next to their forward counterparts.
--
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center