public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@linux-m68k.org>
To: Vincent Lefevre <vincent@vinc17.net>
Cc: Alejandro Colomar <alx.manpages@gmail.com>,
	 libc-alpha@sourceware.org,
	Stephan Bergmann <sbergman@redhat.com>,
	 Paul Eggert <eggert@cs.ucla.edu>,
	 Simon Chopin <simon.chopin@canonical.com>
Subject: Re: UB status of snprintf on invalid ptr+size combination?
Date: Mon, 20 Mar 2023 00:24:51 +0100	[thread overview]
Message-ID: <87ilewiat8.fsf@igel.home> (raw)
In-Reply-To: <20230319224809.GC390223@zira.vinc17.org> (Vincent Lefevre's message of "Sun, 19 Mar 2023 23:48:09 +0100")

On Mär 19 2023, Vincent Lefevre wrote:

> On 2023-03-18 16:01:07 +0100, Andreas Schwab wrote:
>> On Mär 18 2023, Vincent Lefevre wrote:
>> 
>> > However, I'm wondering whether such a change is intentional. BTW,
>> > this description is even wrong: this is certainly not equivalent!
>> > If the untruncated output is larger than n, then the call is UB
>> > with sprintf(), while the output is truncated with snprintf().
>> 
>> Which makes them equivalent in all situations where sprintf is defined,
>> so there is no discrepancy here.
>
> The conditions under which the function is defined or not are part of
> the equivalence.

No, it isn't.  Equivalent is not the same as identical.

> For instance, I would not say that memcpy and memmove are equivalent,
> even though they are equivalent when memcpy is defined.

But they are.  You can use either memcpy or memove in all situations
where memcpy is defined.  Outside of the domain of memcpy there is no
relation at all.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

  reply	other threads:[~2023-03-19 23:24 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14 19:47 Simon Chopin
2023-03-14 21:39 ` Paul Eggert
2023-03-15  9:22   ` Andreas Schwab
2023-03-15 15:54     ` Siddhesh Poyarekar
2023-03-15 18:34     ` Michael Hudson-Doyle
2023-03-19 14:45     ` manfred
2023-03-19 23:07       ` Vincent Lefevre
2023-03-20 12:05         ` Siddhesh Poyarekar
2023-03-20 12:17           ` Alejandro Colomar
2023-03-20 12:29             ` Siddhesh Poyarekar
2023-03-20 13:36             ` Vincent Lefevre
2023-03-20 13:50           ` Vincent Lefevre
2023-03-20 16:56             ` Siddhesh Poyarekar
2023-03-20 17:36               ` Vincent Lefevre
2023-03-20 15:09       ` Vincent Lefevre
2023-03-20 16:15         ` Alejandro Colomar
2023-03-20 16:33           ` Vincent Lefevre
2023-03-20 17:00           ` Vincent Lefevre
2023-03-20 17:31             ` Siddhesh Poyarekar
2023-03-20 17:45               ` Vincent Lefevre
2023-03-15 12:39   ` Vincent Lefevre
2023-03-16 10:29     ` Stephan Bergmann
2023-03-18  2:07       ` Vincent Lefevre
2023-03-18  2:30         ` Alejandro Colomar
2023-03-18 10:58           ` Vincent Lefevre
2023-03-18 15:01             ` Andreas Schwab
2023-03-19 22:48               ` Vincent Lefevre
2023-03-19 23:24                 ` Andreas Schwab [this message]
2023-03-20  4:10                   ` Vincent Lefevre
2023-03-20  9:19                     ` Andreas Schwab
2023-03-20 10:42                       ` Vincent Lefevre
2023-03-20 10:44                         ` Andreas Schwab

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ilewiat8.fsf@igel.home \
    --to=schwab@linux-m68k.org \
    --cc=alx.manpages@gmail.com \
    --cc=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.org \
    --cc=sbergman@redhat.com \
    --cc=simon.chopin@canonical.com \
    --cc=vincent@vinc17.net \
    /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.
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).