|
|
Message-ID: <2976941.0vhOF50zNu@nimes>
Date: Mon, 12 Jun 2023 16:44:44 +0200
From: Bruno Haible <bruno@...sp.org>
To: musl@...ts.openwall.com
Subject: swprintf %lc directive does not work for some wide characters
According to ISO C 11 § 7.29.2.1, in the *wprintf family of functions, the
%lc directive works like this:
"[If an l length modifier is present,] the wint_t argument is converted to
wchar_t and written."
Likewise in ISO C 17 § 7.29.2 and ISO C 23 § 7.31.2.1 and in POSIX:2018
<https://pubs.opengroup.org/onlinepubs/9699919799/functions/fwprintf.html>.
In musl libc 1.2.4 (as part of Alpine Linux 3.18.0) this does not work for
some characters.
How to reproduce:
=================================== foo.c ===================================
#include <stdio.h>
#include <wchar.h>
int main ()
{
static wint_t L_invalid = (wchar_t) 0x76543210;
wchar_t buf[3];
int ret = swprintf (buf, 3, L"%lc", L_invalid);
if (ret >= 0)
fprintf (stderr, "OK, %d characters\n", ret);
else
perror ("swprintf failed");
}
=============================================================================
$ gcc -Wall foo.c
$ ./a.out
Expected output:
OK, 1 characters
Actual output:
swprintf failed: Illegal byte sequence
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.