unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Richard Stallman <rms@gnu.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: gerd.moellmann@gmail.com, 58966@debbugs.gnu.org,
	stefankangas@gmail.com, jacob.fai@gmail.com
Subject: bug#58966: [Trunk] Xcode 14.1+ (and macOS 13.0+) deprecate sprintf()
Date: Mon, 07 Nov 2022 02:46:45 -0500	[thread overview]
Message-ID: <E1orwqD-0003mU-W3@fencepost.gnu.org> (raw)
In-Reply-To: <be1f3a8d-1f14-00d7-b69e-2c3b30dd78f1@cs.ucla.edu> (message from Paul Eggert on Sat, 5 Nov 2022 13:00:25 -0700)

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > While we're on the topic: sprintf and snprintf both have serious design 
  > flaws, in that they cannot generate output longer than INT_MAX bytes, 
  > and this contradicts the GNU design philosophy to avoid arbitrary 
  > limits.

I principle, yes.  But most of the calls to sprintf I saw seem to
generate output that is very limited in size, so there is no danger
of buffer overflow in practice.

  >  > We could switch to snprintf, and define snprintf to call sprintf
  >  > in systems where snprintf isn't available.

  > That wouldn't that easy to do,

What is hard about it?

  > > It is possible to verify
  > > that sprintf did not overwrite the buffer.

  > Sorry, I don't know what this comment is trying to say.

Sorry if that was too terse.

If we define snpritf to call sprintf on some platforms, as I suggested
as a fallback, that definition can check the return value of sprintf
to make sure that sprintf did not overflow the output buffer that
snprintf was given.  It can call fatal if that overflow occurs.

  > In my experience, with a debugging runtime sprintf is better than 
  > snprintf, as sprintf reliably reports bugs

What is a "debugging runtime"?

sprintf can't try to detect overflow of the output buffer, because
nothing tells sprintf how big the buffer is.



-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)







      reply	other threads:[~2022-11-07  7:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-02 13:56 bug#58966: [Trunk] Xcode 14.1+ (and macOS 13.0+) deprecate sprintf() Jacob Faibussowitsch
2022-11-03  5:56 ` Gerd Möllmann
2022-11-03  8:16   ` Eli Zaretskii
2022-11-03  9:00     ` Gerd Möllmann
2022-11-03  9:15       ` Eli Zaretskii
2022-11-03  9:36         ` Gerd Möllmann
2022-11-03 14:40           ` Jacob Faibussowitsch
2022-11-03 14:43             ` Gerd Möllmann
2022-11-03 14:48               ` Jacob Faibussowitsch
2022-11-03 15:22                 ` Gerd Möllmann
2022-11-03 15:30                   ` Jacob Faibussowitsch
2022-11-03 16:15                     ` Gerd Möllmann
2022-11-03 16:19                       ` Gerd Möllmann
2022-11-03 18:30 ` Paul Eggert
2022-11-04 21:07   ` Jacob Faibussowitsch
2022-11-05  3:12   ` Richard Stallman
2022-11-05 16:26     ` Stefan Kangas
2022-11-05 20:00       ` Paul Eggert
2022-11-07  7:46         ` Richard Stallman [this message]

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=E1orwqD-0003mU-W3@fencepost.gnu.org \
    --to=rms@gnu.org \
    --cc=58966@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=gerd.moellmann@gmail.com \
    --cc=jacob.fai@gmail.com \
    --cc=stefankangas@gmail.com \
    /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).