diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2024-04-09 22:30:03 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2024-04-09 22:30:03 +0200 |
commit | 579064bf4d408e99ed7556f36a3050c7ee99dee6 (patch) | |
tree | 94d72da8df08f934166aa1624c9dac6125a3be53 /winsup/cygwin/dcrt0.cc | |
parent | 2855c35c41ed5c950e40ce0ae0d99d00185e05ad (diff) | |
download | newlib-579064bf4d408e99ed7556f36a3050c7ee99dee6.zip newlib-579064bf4d408e99ed7556f36a3050c7ee99dee6.tar.gz newlib-579064bf4d408e99ed7556f36a3050c7ee99dee6.tar.bz2 |
Cygwin: globify: read full 32 bit character
While commit 0321fb573654 ("Cygwin: glob: convert wchar_t to wint_t")
switched the entire glob mechanism from wchar_t to wint_t, the globify
function calling glob on a DOS command line did not catch up and only
checked for the next character constituting a 16 bit wchar_t. This
broke reading surrogate pairs from incoming DOS command lines if the
string had to go through glob(3).
Check for an entire 32 bit unicode char instead.
Fixes: 0321fb573654 ("Cygwin: glob: convert wchar_t to wint_t")
Reported-by: David Allsopp <david@tarides.com>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/dcrt0.cc')
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 7229377..f4c09be 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 |