From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by sourceware.org (Postfix) with ESMTPS id 51C203858D37 for ; Sun, 19 Mar 2023 23:24:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 51C203858D37 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nefkom.net Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Pfv910NN0z1r1NP; Mon, 20 Mar 2023 00:24:52 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Pfv905vsHz1qqlY; Mon, 20 Mar 2023 00:24:52 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id F5QZdL1wWQxl; Mon, 20 Mar 2023 00:24:51 +0100 (CET) X-Auth-Info: BWtxom3ALQaoGPFRl+awKptdJFE69aEW9KsNmHkxaWRvIUeC3KItkBKZmjwkDUr9 Received: from igel.home (aftr-82-135-86-168.dynamic.mnet-online.de [82.135.86.168]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Mon, 20 Mar 2023 00:24:51 +0100 (CET) Received: by igel.home (Postfix, from userid 1000) id 9F4402C15E4; Mon, 20 Mar 2023 00:24:51 +0100 (CET) From: Andreas Schwab To: Vincent Lefevre Cc: Alejandro Colomar , libc-alpha@sourceware.org, Stephan Bergmann , Paul Eggert , Simon Chopin Subject: Re: UB status of snprintf on invalid ptr+size combination? References: <20230315123949.GC73312@zira.vinc17.org> <92810b6e-e7e6-6ffd-d33a-067b9f300059@redhat.com> <20230318020725.GA15308@zira.vinc17.org> <9c8cae93-cb8c-8689-1f0e-2b87514d3702@gmail.com> <20230318105827.GB15308@zira.vinc17.org> <875yayyuh8.fsf@igel.home> <20230319224809.GC390223@zira.vinc17.org> X-Yow: A GRAM?? A BRAM... A GROOM... A BROOM... Oh, Yeh!! Wash the ROOM!! Date: Mon, 20 Mar 2023 00:24:51 +0100 In-Reply-To: <20230319224809.GC390223@zira.vinc17.org> (Vincent Lefevre's message of "Sun, 19 Mar 2023 23:48:09 +0100") Message-ID: <87ilewiat8.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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."