From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 133A33858404; Fri, 9 Feb 2024 22:05:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 133A33858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1707516343; bh=7sfJ2s1nkT9D5m3XDYmZfNiyqcucJSY3S+SOZ6MSGWY=; h=From:To:Subject:Date:From; b=OplS4lfyM2dx7dGJ3n2nCMLxYfOsK+qdW/2mWFRTI6YO9Nezs7WTmO67rDjPuloeC u760SJF4FU7AEcwipvZj5XBafFv5LkGp5WYg5UTNooewkLwxiQ5m/F1wUq/MsMxE15 EKbQl8pFCvLBGdoi6GCw3j+RcJis5JSYJ4cvWtQw= From: "bruno at clisp dot org" To: glibc-bugs@sourceware.org Subject: [Bug string/31365] New: wcsftime produces invalid characters when the time's weekday or month is out-of-range Date: Fri, 09 Feb 2024 22:05:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: string X-Bugzilla-Version: 2.38 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bruno at clisp dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31365 Bug ID: 31365 Summary: wcsftime produces invalid characters when the time's weekday or month is out-of-range Product: glibc Version: 2.38 Status: UNCONFIRMED Severity: normal Priority: P2 Component: string Assignee: unassigned at sourceware dot org Reporter: bruno at clisp dot org Target Milestone: --- The wcsftime function is meant to produce, when the given time's weekday or month is out-of-range, a result with question marks, like strftime does. This works on little-endian platforms. But it does not work on big-endian platforms. How to reproduce: Compile and run this program. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D foo.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D #include #include #include #include #include #include #include int main () { time_t t =3D 1509000003; struct tm *tm =3D gmtime (&t); wchar_t buf[100]; size_t n; tm->tm_wday =3D -1; tm->tm_mon =3D -1; errno =3D 0; n =3D wcsftime (buf, sizeof buf / sizeof (wchar_t), L"|%a| %Y-%b-%d %H:%M= :%S", tm); if (n =3D=3D 0) { perror ("wcsftime"); } else { printf ("wcsftime output:\n"); for (size_t i =3D 0; i < n; i++) printf ("U+0x%04x ", (unsigned int) buf[i]); printf ("\n"); if (printf ("Converted to ASCII: %ls\n", buf) < 0) printf ("Conversion to ASCII failed.\n"); } } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Output on ia64, ppc64le, riscv64, loongarch64: --------------------------------------------------------------------- wcsftime output: U+0x007c U+0x003f U+0x007c U+0x0020 U+0x0032 U+0x0030 U+0x0031 U+0x0037 U+0x002d U+0x003f U+0x002d U+0x0032 U+0x0036 U+0x0020 U+0x0030 U+0x0036 U+0x003a U+0x0034 U+0x0030 U+0x003a U+0x0030 U+0x0033=20 Converted to ASCII: |?| 2017-?-26 06:40:03 --------------------------------------------------------------------- Output on mips64eb, powerpc64, sparc: --------------------------------------------------------------------- wcsftime output: U+0x007c U+0x3f000000 U+0x007c U+0x0020 U+0x0032 U+0x0030 U+0x0031 U+0x0037 U+0x002d U+0x3f000000 U+0x002d U+0x0032 U+0x0036 U+0x0020 U+0x0030 U+0x0036 U+0x003a U+0x0034 U+0x0030 U+0x003a U+0x0030 U+0x0033=20 Conversion to ASCII failed. --------------------------------------------------------------------- Output on hppa: --------------------------------------------------------------------- wcsftime output: U+0x007c U+0x3f000000 U+0x2e2e2f73 U+0x79736465 U+0x70732f75 U+0x6e69782f U+0x73797376 U+0x2f6c696e U+0x75782f74 U+0x656c6c64 U+0x69722e63 U+0x007c U+0x0020 U+0x0032 U+0x0030 U+0x0031 U+0x0037 U+0x002d U+0x3f000000 U+0x2e2e= 2f73 U+0x79736465 U+0x70732f75 U+0x6e69782f U+0x73797376 U+0x2f6c696e U+0x75782f= 74 U+0x656c6c64 U+0x69722e63 U+0x002d U+0x0032 U+0x0036 U+0x0020 U+0x0030 U+0x= 0036 U+0x003a U+0x0034 U+0x0030 U+0x003a U+0x0030 U+0x0033=20 Conversion to ASCII failed. --------------------------------------------------------------------- --=20 You are receiving this mail because: You are on the CC list for the bug.=