From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Jan_Dj=E4rv?= Newsgroups: gmane.emacs.devel Subject: Re: fix the sscanf usage in etags Date: Wed, 09 Aug 2006 08:57:15 +0200 Message-ID: <44D9874B.3040206@swipnet.se> References: <20060807.123850.192456906.jet@gyve.org> <87psfa93i7.fsf@zip.com.au> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1155106710 6501 80.91.229.2 (9 Aug 2006 06:58:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 9 Aug 2006 06:58:30 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 09 08:58:26 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GAi1J-0006bJ-2s for ged-emacs-devel@m.gmane.org; Wed, 09 Aug 2006 08:58:25 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GAi1I-0000K5-OH for ged-emacs-devel@m.gmane.org; Wed, 09 Aug 2006 02:58:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GAi16-0000K0-9O for emacs-devel@gnu.org; Wed, 09 Aug 2006 02:58:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GAi12-0000Ho-NL for emacs-devel@gnu.org; Wed, 09 Aug 2006 02:58:10 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GAi12-0000Hl-H1 for emacs-devel@gnu.org; Wed, 09 Aug 2006 02:58:08 -0400 Original-Received: from [81.228.9.185] (helo=av9-1-sn3.vrr.skanova.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GAi5f-0005Bw-GP for emacs-devel@gnu.org; Wed, 09 Aug 2006 03:02:55 -0400 Original-Received: by av9-1-sn3.vrr.skanova.net (Postfix, from userid 502) id 6F0E238074; Wed, 9 Aug 2006 08:58:07 +0200 (CEST) Original-Received: from smtp3-2-sn3.vrr.skanova.net (smtp3-2-sn3.vrr.skanova.net [81.228.9.102]) by av9-1-sn3.vrr.skanova.net (Postfix) with ESMTP id 60E2C37E46; Wed, 9 Aug 2006 08:58:07 +0200 (CEST) Original-Received: from coolsville.localdomain (81-235-205-204-no59.tbcn.telia.com [81.235.205.204]) by smtp3-2-sn3.vrr.skanova.net (Postfix) with ESMTP id 6956837E43; Wed, 9 Aug 2006 08:58:06 +0200 (CEST) User-Agent: Thunderbird 1.5.0.4 (X11/20060614) Original-To: Kevin Ryde In-Reply-To: <87psfa93i7.fsf@zip.com.au> X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:58210 Archived-At: Kevin Ryde skrev: > Masatake YAMATO writes: >> - if (sscanf (lbp->buffer, "#line %d \"%n", &lno, &start) == 1) >> + if (sscanf (lbp->buffer, "#line %d \"%n", &lno, &start) == 2) > > I think that's wrong, I believe %n is not included in the return > count. Eg. in the current glibc, and in the posix spec (under "n"), > > http://www.opengroup.org/onlinepubs/007904975/functions/scanf.html > The man page on GNU/Linux says: The C standard says: "Execution of a %n directive does not increment the assignment count returned at the comple- tion of execution" but the Corrigendum seems to contradict this. Probably it is wise not to make any assumptions on the effect of %n conversions on the return value. So I guess we safely can test for >= 1 instead for those implementations that do return 2. I've checked in that change. > It does look like there's a problem with degenerate input having > "start" used uninitialized though. Eg. say > > #line 00000000000000000000000000000 We can switch places between \" and %n and check for ": if (sscanf (lbp->buffer, "#line %d %n\"", &lno, &start) >= 1 && lbp->buffer[start] == '"') { char *endp = lbp->buffer + ++start; Jan D.