This is the mail archive of the gdb-patches@sources.redhat.com 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]

Re: Minor off-by-one error in command_line_handler


Elena Zannoni <ezannoni@redhat.com> writes:

|> Andrew Cagney writes:
|>  > > 2002-03-26  Jason Molenda  (jason-cl@molenda.com)
|>  > > 
|>  > > 	* event-top.c (command_line_handler): Don't check penultimate
|>  > > 	byte in zero-length strings.
|>  > > 
|>  > > 
|>  > Yes, and thanks.
|>  > 
|>  > Andrew
|>  > 
|>  > 
|> 
|> Wait.  This is fine, but, as the comments indicate, the code was taken
|> from the function command_line_input in top.c, which has the same bug:
|> 
|>       p1 = rl;
|>       /* Copy line.  Don't copy null at end.  (Leaves line alone
|>          if this was just a newline)  */
|>       while (*p1)
|> 	*p++ = *p1++;
|> 
|>       xfree (rl);		/* Allocated in readline.  */
|> 
|>       if (p == linebuffer || *(p - 1) != '\\')
|> 	break;

Why?  This one looks ok.

Btw., command_line_handler has this:


  if (*(p - 1) == '\\')
    {
      p--;			/* Put on top of '\'.  */

      if (*p == '\\')

The condition in the last line is always true.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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