From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10101 invoked by alias); 27 Mar 2002 21:31:20 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 10063 invoked from network); 27 Mar 2002 21:31:15 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 27 Mar 2002 21:31:15 -0000 Received: from localhost.redhat.com (cse.cygnus.com [205.180.230.236]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id NAA02775; Wed, 27 Mar 2002 13:31:04 -0800 (PST) Received: by localhost.redhat.com (Postfix, from userid 469) id 2821F11429; Wed, 27 Mar 2002 16:03:44 -0500 (EST) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Message-ID: <15522.13231.951795.389737@localhost.redhat.com> Date: Wed, 27 Mar 2002 13:31:00 -0000 To: Andreas Schwab Cc: Elena Zannoni , Andrew Cagney , Jason Molenda , gdb-patches@sources.redhat.com Subject: Re: Minor off-by-one error in command_line_handler In-Reply-To: References: <20020327000106.A24311@molenda.com> <3CA1F421.6010009@cygnus.com> <15522.2853.891361.517767@localhost.redhat.com> X-SW-Source: 2002-03/txt/msg00551.txt.bz2 Andreas Schwab writes: > Elena Zannoni writes: >=20 > |> Andrew Cagney writes: > |> > > 2002-03-26 Jason Molenda (jason-cl@molenda.com) > |> > >=20 > |> > > * event-top.c (command_line_handler): Don't check penultimate > |> > > byte in zero-length strings. > |> > >=20 > |> > >=20 > |> > Yes, and thanks. > |> >=20 > |> > Andrew > |> >=20 > |> >=20 > |>=20 > |> 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: > |>=20 > |> p1 =3D rl; > |> /* Copy line. Don't copy null at end. (Leaves line alone > |> if this was just a newline) */ > |> while (*p1) > |> *p++ =3D *p1++; > |>=20 > |> xfree (rl); /* Allocated in readline. */ > |>=20 > |> if (p =3D=3D linebuffer || *(p - 1) !=3D '\\') > |> break; >=20 > Why? This one looks ok. Oh, You mean because the second part of the 'or' won't be evaluated if=20 p=3D=3Dlinebuffer (which implies that the line was empty)? Wonder if this gives an error if run under valgrind (use the --noasync switch).=20 Looking at the logs, the error in event-top.c came in because that first part of the OR was deleted. >=20 > Btw., command_line_handler has this: >=20 >=20 > if (*(p - 1) =3D=3D '\\') > { > p--; /* Put on top of '\'. */ >=20 > if (*p =3D=3D '\\') >=20 > The condition in the last line is always true. >=20 Yes, thanks for catching this. Would you like to submit a fix? Elena > Andreas. >=20 > --=20 > Andreas Schwab, SuSE Labs, schwab@suse.de > SuSE GmbH, Deutschherrnstr. 15-19, D-90429 N=FCrnberg > Key fingerprint =3D 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 > "And now for something completely different."