unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: 9412@debbugs.gnu.org
Subject: bug#9412: sprintf-related integer and memory overflow issues
Date: Wed, 31 Aug 2011 12:14:13 -0400	[thread overview]
Message-ID: <871uw136ei.fsf@stupidchicken.com> (raw)
In-Reply-To: <4E5DCE9B.9060903@cs.ucla.edu> (Paul Eggert's message of "Tue, 30 Aug 2011 23:03:07 -0700")

Paul Eggert <eggert@cs.ucla.edu> writes:

> In code that is formatting buffers or strings that might be longer
> than 2 GiB, we cannot use sprintf etc.  We need to fix these issues
> somehow.  If there's a better way than esprintf etc. please let me
> know.
>
> Anyway, I don't quite follow why using esprintf etc. makes the calling
> code much less clear.  esprintf is like sprintf, except that on 64-bit
> hosts esprintf doesn't have sprintf's 2 GiB limit.  If the use of
> esprintf is unclear, then surely the use of sprintf is just as
> unclear.

sprintf (and snprintf) is a well-known function; when someone comes
across it in the code, it's not necessary to look it up to know what
it's doing.

But I'm not clear on this issue of sprintf etc being restricted to 2GB.
Could you explain further?  Surely such a limitation is a bug in the C
library, not Emacs?  If so, it should be fixed there, not in Emacs.

> Although that used to be true, I expect that platforms lacking
> snprintf (e.g., Solaris 2.5.1, IRIX 5.3, OSF/1 4.0) are no longer of
> practical importance as Emacs porting targets.
>
> That being said, it's easy to allay this concern, by using esnprintf
> instead of snprintf in all areas of the code that might run on ancient
> platforms.  The following further patch does this.

I think we should add a stub for snprintf in sysdep.c for the
!HAVE_SNPRINTF case (which will need configure to set up HAVE_SNPRINTF).





  reply	other threads:[~2011-08-31 16:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-30 22:42 bug#9412: sprintf-related integer and memory overflow issues Paul Eggert
2011-08-31  2:08 ` Chong Yidong
2011-08-31  6:03   ` Paul Eggert
2011-08-31 16:14     ` Chong Yidong [this message]
2011-08-31 22:21       ` Paul Eggert
2011-09-01  2:42         ` Chong Yidong
2011-09-01  5:44           ` Paul Eggert
2011-08-31 16:53     ` Dan Nicolaescu

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=871uw136ei.fsf@stupidchicken.com \
    --to=cyd@stupidchicken.com \
    --cc=9412@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    /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).