Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Elena Zannoni <ezannoni@redhat.com>
To: Andreas Schwab <schwab@suse.de>
Cc: Elena Zannoni <ezannoni@redhat.com>,
	Andrew Cagney <ac131313@cygnus.com>,
	Jason Molenda <jason-swarelist@molenda.com>,
	gdb-patches@sources.redhat.com
Subject: Re: Minor off-by-one error in command_line_handler
Date: Wed, 27 Mar 2002 13:31:00 -0000	[thread overview]
Message-ID: <15522.13231.951795.389737@localhost.redhat.com> (raw)
In-Reply-To: <jelmcdlrbm.fsf@sykes.suse.de>

Andreas Schwab writes:
 > 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.

Oh, You mean because the second part of the 'or' won't be evaluated if 
p==linebuffer (which implies that the line was empty)?

Wonder if this gives an error if run under valgrind (use the --noasync
switch). 

Looking at the logs, the error in event-top.c came in because that
first part of the OR was deleted.

 > 
 > 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.
 > 

Yes, thanks for catching this. Would you like to submit a fix?

Elena


 > 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."


  reply	other threads:[~2002-03-27 21:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-27  0:01 Jason Molenda
2002-03-27  8:34 ` Andrew Cagney
2002-03-27 10:11   ` Elena Zannoni
2002-03-27 11:54     ` Andreas Schwab
2002-03-27 13:31       ` Elena Zannoni [this message]
2002-03-27 13:21         ` Andreas Schwab
2002-03-27  9:40 ` Andrew Cagney
2002-03-28 23:54 ` Daniel Jacobowitz
2002-03-30 21:05   ` Andrew Cagney
2002-03-30 21:08     ` Daniel Jacobowitz
2002-04-03 19:27       ` Andrew Cagney
2002-04-09 13:52     ` Daniel Jacobowitz

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=15522.13231.951795.389737@localhost.redhat.com \
    --to=ezannoni@redhat.com \
    --cc=ac131313@cygnus.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=jason-swarelist@molenda.com \
    --cc=schwab@suse.de \
    /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