diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index ea6a18b51..ff7e6ec50 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -236,12 +236,13 @@ globify (char *word, char **&argv, int &argc, int &argvlen) char quote = *s; while (*++s && *s != quote) { + mbstate_t mbs = { 0 }; if (dos_spec || *s != '\\') /* nothing */; else if (s[1] == quote || s[1] == '\\') s++; *p++ = '\\'; - size_t cnt = isascii (*s) ? 1 : mbtowc (NULL, s, MB_CUR_MAX); + size_t cnt = isascii (*s) ? 1 : mbrtowi (NULL, s, MB_CUR_MAX, &mbs); if (cnt <= 1 || cnt == (size_t)-1) *p++ = *s; else diff --git a/winsup/cygwin/release/3.5.4 b/winsup/cygwin/release/3.5.4 index e2bd02531..e1909865f 100644 --- a/winsup/cygwin/release/3.5.4 +++ b/winsup/cygwin/release/3.5.4 @@ -4,3 +4,7 @@ Fixes: - Fix regression in 3.5.3 which fails to open files for stat(2) if the file is opened exclusively by another process. Addresses: https://cygwin.com/pipermail/cygwin/2024-April/255811.html + +- Fix regression introduced in 3.5.0 when reading surrogate pairs (i.e., + unicode chars >= 0x10000) from the DOS command line. Addresses: + https://cygwin.com/pipermail/cygwin/2024-April/255807.html