[newlib-cygwin/main] Cygwin: glob: fix conversion from UTF-32 to multibyte

Corinna Vinschen corinna@sourceware.org
Fri Mar 3 17:20:29 GMT 2023


commit 6bc687e35d6a74b4b9d8531c73b3f6cc571bc744
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Fri Mar 3 11:32:31 2023 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Fri Mar 3 18:19:17 2023 +0100

    Cygwin: glob: fix conversion from UTF-32 to multibyte
    The conversion function g_Ctoc missed to drop the flag
    values from the wint_t value.  That wasn't noticable with
    the original version because it used a 64 bit Char type
    and the flags were in the upper 32 bit region.  So the
    flag values were silently dropped when wcrtomb was called.
    After converting Char to wint_t, we have to do drop the
    flags explicitely.
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

 winsup/cygwin/glob.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/glob.cc b/winsup/cygwin/glob.cc
index dadc67e4c10a..4730d09f5590 100644
--- a/winsup/cygwin/glob.cc
+++ b/winsup/cygwin/glob.cc
@@ -130,7 +130,7 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/glob.c,v 1.28 2010/05/12 17:44:00 gordon Ex
 #define	M_PROTECT	0x20000000U
 #define	M_MASK		0x70ffffffU
 #define	M_COLL_MASK	0x700000ffU
-#define	M_CHAR		0x0fffffffU
+#define	M_CHAR		0x00ffffffU
 typedef wint_t Char;
@@ -1030,7 +1030,7 @@ g_Ctoc(const Char *str, char *buf, size_t len)
 	memset(&mbs, 0, sizeof(mbs));
 	while (len >= (size_t) MB_CUR_MAX) {
-		clen = wirtomb(buf, *str, &mbs);
+		clen = wirtomb(buf, CHAR (*str), &mbs);
 		if (clen == (size_t)-1)
 			return (1);
 		if (*str == L'\0')

More information about the Cygwin-cvs mailing list