unistdio/u*-vasnprintf: Fix conversion of %Id directive result.
authorBruno Haible <bruno@clisp.org>
Wed, 22 Mar 2023 05:13:18 +0000 (06:13 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 22 Mar 2023 21:54:30 +0000 (22:54 +0100)
* lib/vasnprintf.c (VASNPRINTF): Don't assume that snprintf's result is
entirely ASCII if the directive contain the glibc 'I' flag.

ChangeLog
lib/vasnprintf.c

index 0269b3c9fff3f305b12b3960388968e352a1d0e8..d57580ae2aaac394e9cb62eadfc7558ccbbd0b9b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-03-21  Bruno Haible  <bruno@clisp.org>
+
+       unistdio/u*-vasnprintf: Fix conversion of %Id directive result.
+       * lib/vasnprintf.c (VASNPRINTF): Don't assume that snprintf's result is
+       entirely ASCII if the directive contain the glibc 'I' flag.
+
 2023-03-21  Ar Rakin  <rakinar2@onesoftnet.eu.org>  (tiny change)
 
        gnupload: correct SFTP connection URL
index ad61dbba92e563fffebfbb1665d0f6b797ec7450..957da484c2abd3c99ead20f1c483eca800427259 100644 (file)
@@ -5448,11 +5448,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 
 #if !DCHAR_IS_TCHAR
                     /* Convert from TCHAR_T[] to DCHAR_T[].  */
-                    if (dp->conversion == 'c' || dp->conversion == 's')
+                    if (dp->conversion == 'c' || dp->conversion == 's'
+# if __GLIBC__ >= 2 && !defined __UCLIBC__
+                        || (flags & FLAG_LOCALIZED)
+# endif
+                       )
                       {
-                        /* type = TYPE_CHAR or TYPE_WIDE_CHAR or TYPE_STRING
-                           TYPE_WIDE_STRING.
-                           The result string is not certainly ASCII.  */
+                        /* The result string is not guaranteed to be ASCII.  */
                         const TCHAR_T *tmpsrc;
                         DCHAR_T *tmpdst;
                         size_t tmpdst_len;