From: "Jan Djärv" <jan.h.d@swipnet.se>
Cc: emacs-devel@gnu.org
Subject: Re: fix the sscanf usage in etags
Date: Wed, 09 Aug 2006 08:57:15 +0200 [thread overview]
Message-ID: <44D9874B.3040206@swipnet.se> (raw)
In-Reply-To: <87psfa93i7.fsf@zip.com.au>
Kevin Ryde skrev:
> Masatake YAMATO <jet@gyve.org> 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.
next prev parent reply other threads:[~2006-08-09 6:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-07 3:38 fix the sscanf usage in etags Masatake YAMATO
2006-08-08 9:35 ` Jan Djärv
2006-08-09 0:06 ` Kevin Ryde
2006-08-09 6:57 ` Jan Djärv [this message]
2006-08-09 7:57 ` Masatake YAMATO
2006-08-09 13:20 ` Jan Djärv
2006-08-09 14:10 ` Masatake YAMATO
2006-08-10 0:15 ` Kevin Ryde
2006-08-10 6:47 ` Jan Djärv
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44D9874B.3040206@swipnet.se \
--to=jan.h.d@swipnet.se \
--cc=emacs-devel@gnu.org \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).