public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: globify: read full 32 bit character
@ 2024-04-09 20:37 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2024-04-09 20:37 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=579064bf4d408e99ed7556f36a3050c7ee99dee6

commit 579064bf4d408e99ed7556f36a3050c7ee99dee6
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Tue Apr 9 22:30:03 2024 +0200
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Tue Apr 9 22:30:03 2024 +0200

    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>

Diff:
---
 winsup/cygwin/dcrt0.cc      | 3 ++-
 winsup/cygwin/release/3.5.4 | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 7229377eb3fe..f4c09befd62c 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 e2bd025317e9..e1909865f362 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-09 20:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-09 20:37 [newlib-cygwin/main] Cygwin: globify: read full 32 bit character Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).