From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 25485 invoked from network); 14 Nov 2023 13:23:02 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 14 Nov 2023 13:23:02 -0000 Received: (qmail 11728 invoked by uid 550); 14 Nov 2023 13:22:59 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 11693 invoked from network); 14 Nov 2023 13:22:59 -0000 ARC-Seal: i=1; a=rsa-sha256; t=1699968167; cv=none; d=strato.com; s=strato-dkim-0002; b=oBFeZnB8NT5Ej9BBEDQCRSSmV97EDFTfSsy/Dlg+gS15DjNv5l4ddgzVbH/S9/uhKS SyYpeVW+5WBUkKeXaJd24UQRifvPV22StH6f1DlPPL6Pg1Rn8vAwD6T9gyqvRX42uK09 xw4z+tpldEo0y1IxmfObfLVECdl0ntPUnaLLZPFrE2wOboQ977jpC0Nq8Dxh0eNznBAd HN4holxeLt1JMvYPQFHiC1X6lttn5idv/MsgR+6xavKBFYLW7p1bbmFGepDvWnHouPXF T6QYg95XAX89TsG9GiuCvTR/kDVTpU6jZCZ5i5aK/Je387ln9MNlRolgNXgyfF7H5Xjx d+Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1699968167; s=strato-dkim-0002; d=strato.com; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=tPXMY7tucWJI+d8jETLXMxfiKLpOUkVbt3FoV8esV28=; b=EXXQ4D1SlUcL/nLR6AtXIoGnKG2xVmpkToLtG5N2K4Y1u/YgliEDdGveEi567yuWxg myYomQc0FB3Frk6GutUvZc4c7i6CDXru6wJLEjUvobTX5iSkynIZa0O1oNuYBCsr2WCw WTAz30xfIld63r0f0joCVJBfoBEIkMdXUisFmptAeQLKCzmP838HDInODEnDpjz5ULig BMjQjUWPSmykJBnYQzLyknpOI6Zd6wUIm44LodmI/53r9eHMAZKMDnjYWD53BWFf4VuV nEGyX24i0fLYAdCuEf8xXjpftknW8PIYd8fR6kRr6SePsa54ZofXjZ3Vuh8HL/nEXIdf Vv4A== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1699968167; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=tPXMY7tucWJI+d8jETLXMxfiKLpOUkVbt3FoV8esV28=; b=n6Hds3pzEe2xRpjzJwzz2tMVdc9g/ZuNYx7cBzc1+NsQeaCcwVHDrqtEt1DxjlyeOi VEEoz3xQknPQtCl0etzrk7RRcli6uYogy/JQAF2ZG3tjHxlcJUEe3/lWbxxb8yqkDH/H TCmjAtyks3QlfVY5lT+Wxp0xVKbPqHw3tCshgS+8pHBmYMD8weHq9x7h1znoND24Eyxp hW+YG5c1Ju6DZO4bxuWrj/pEerqazT3n3RYsFHyPADbEuEigF/aDmtPCc7EaYgp3ZLzL Oo3hsxcjUq94y8dRDdJ5ZKLoTfESFGS+wRVWcQr9WbNchSXJJQyLbk8axI1A995wnOG4 1arw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1699968167; s=strato-dkim-0003; d=clisp.org; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=tPXMY7tucWJI+d8jETLXMxfiKLpOUkVbt3FoV8esV28=; b=Fha8r8I0IovaRowyp4lljGiooVHSEYEJFX21+asRkUOyFPj02Q8x24EJAX4vjqxn0e CPXppTiostEVzuugO+CA== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zq68+3cfpPA3qFfCT9Jw/Et2No03dzxS8YHkA==" From: Bruno Haible To: musl@lists.openwall.com Date: Tue, 14 Nov 2023 14:22:46 +0100 Message-ID: <4798297.Es0HkHt82z@nimes> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: [musl] *printf %lc of L'\0' Hi, On 2023-03-21 I noticed a bug with %lc in most libcs: . On 2023-03-28 Eric Blake opened a defect with POSIX, with the intent that both ISO C and POSIX make the four *printf cases consistent: This issue was then submitted in the ISO C 23 ballot as GB-141, and in the meeting from 2023-06-20 to 2023-06-23 it was decided upon: page 23, 24. The decision ("option 1") is detailed in : "Option 1 (require a NUL) - change the text to: If an l length modifier is present, the wint_t argument is converted as if by a call to the wcrtomb function with a pointer to storage of at least MB_CUR_MAX bytes, the wint_t argument converted to wchar_t, and an initial shift state." So, ISO C changed, and POSIX will follow suit. The bug in most libcs is thus no longer a bug. musl libc, which had it correct, now has a bug. Test case: =============================================================================== #include #include #include int main () { { char buf[12] = { 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD }; wchar_t two_nuls[2] = { 0, 0 }; int ret = snprintf (buf, 12, "a%lsz", two_nuls); printf ("ret = %d, buf[0] = 0x%x, buf[1] = 0x%x, buf[2] = 0x%x, buf[3] = 0x%x\n", ret, (unsigned char) buf[0], (unsigned char) buf[1], (unsigned char) buf[2], (unsigned char) buf[3]); } { char buf[12] = { 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD }; int ret = snprintf (buf, 12, "a%lcz", 0); printf ("ret = %d, buf[0] = 0x%x, buf[1] = 0x%x, buf[2] = 0x%x, buf[3] = 0x%x\n", ret, (unsigned char) buf[0], (unsigned char) buf[1], (unsigned char) buf[2], (unsigned char) buf[3]); } return 0; } /* glibc, *BSD, macOS, AIX, Solaris - all correct now: ret = 2, buf[0] = 0x61, buf[1] = 0x7a, buf[2] = 0x0, buf[3] = 0xdd ret = 3, buf[0] = 0x61, buf[1] = 0x0, buf[2] = 0x7a, buf[3] = 0x0 musl libc - now incorrect: ret = 2, buf[0] = 0x61, buf[1] = 0x7a, buf[2] = 0x0, buf[3] = 0xdd ret = 2, buf[0] = 0x61, buf[1] = 0x7a, buf[2] = 0x0, buf[3] = 0xdd */ =============================================================================== Best regards, Bruno