From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 26B053858D39; Tue, 9 Apr 2024 20:36:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26B053858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1712695010; bh=lwLVgdV7nrbLRr1hapAQNulCxUT940+g/ARogQtdHIM=; h=From:To:Subject:Date:From; b=PxolzX2JqQCuDPFj7I93E6PaePgTNj5sjvAEukM3wbZueVASKmXW/c1b7hUbv4fc+ w7pChegHQUWjzFIqaVZlYeyibHWIS7bMUbxEu+C9yWT+p65xTDuEaMctTr0KO62WH8 im2+t0BjMDxJc1zMs913YSPk/+BZeQ8FXtjWZtNg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_5-branch] Cygwin: globify: read full 32 bit character X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/cygwin-3_5-branch X-Git-Oldrev: e00cb126944e4d4e4b5ca4a2710a52ef6503462b X-Git-Newrev: 14216d5442e04f23f20318b434b3f2bc4c43ca90 Message-Id: <20240409203650.26B053858D39@sourceware.org> Date: Tue, 9 Apr 2024 20:36:50 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D14216d5442e= 04f23f20318b434b3f2bc4c43ca90 commit 14216d5442e04f23f20318b434b3f2bc4c43ca90 Author: Corinna Vinschen AuthorDate: Tue Apr 9 22:30:03 2024 +0200 Commit: Corinna Vinschen CommitDate: Tue Apr 9 22:30:34 2024 +0200 Cygwin: globify: read full 32 bit character =20 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). =20 Check for an entire 32 bit unicode char instead. =20 Fixes: 0321fb573654 ("Cygwin: glob: convert wchar_t to wint_t") Reported-by: David Allsopp Signed-off-by: Corinna Vinschen 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 ea6a18b51d70..ff7e6ec50f54 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -236,12 +236,13 @@ globify (char *word, char **&argv, int &argc, int &ar= gvlen) char quote =3D *s; while (*++s && *s !=3D quote) { + mbstate_t mbs =3D { 0 }; if (dos_spec || *s !=3D '\\') /* nothing */; else if (s[1] =3D=3D quote || s[1] =3D=3D '\\') s++; *p++ =3D '\\'; - size_t cnt =3D isascii (*s) ? 1 : mbtowc (NULL, s, MB_CUR_MAX); + size_t cnt =3D isascii (*s) ? 1 : mbrtowi (NULL, s, MB_CUR_MAX, &mbs); if (cnt <=3D 1 || cnt =3D=3D (size_t)-1) *p++ =3D *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 >=3D 0x10000) from the DOS command line. Addresses: + https://cygwin.com/pipermail/cygwin/2024-April/255807.html