dfda51ee29
Upstream commit: 3ec5d83d2a237d39e7fd6ef7a0bc8ac4c171a4a5 - Drop glibc-fedora-__libc_multiple_libcs.patch. Replaced by upstream's __libc_initial flag. - Adjust glibc-rh819430.patch to upstream's gnulib merge of fnmatch. - Disable -Werror again due to GCC PR98512. - x86-64: Avoid rep movsb with short distance [BZ #27130] - aarch64: fix stack missing after sp is updated - nptl: Remove set*id, set*gid files which are not built - Drop nan-pseudo-number.h usage from tests - posix: Sync fnmatch with gnulib - Sync flexmember.h with gnulib - Sync intprops.h with gnulib - posix: Sync glob code with gnulib - posix: Sync regex code with gnulib - Move generic nan-pseudo-number.h to ldbl-96 - Sync FDL from https://www.gnu.org/licenses/fdl-1.3.texi - Sync move-if-change from Gnulib - Update automatically-generated copyright dates - Update copyright dates not handled by scripts/update-copyrights. - Update copyright dates with scripts/update-copyrights - aarch64: use PTR_ARG and SIZE_ARG instead of DELOUSE - nonstring: Enable __FORTIFY_LEVEL=3 - string: Enable __FORTIFY_LEVEL=3 - Introduce _FORTIFY_SOURCE=3 - Warn on unsupported fortification levels - powerpc: Use scv instruction on clone when available - powerpc: Runtime selection between sc and scv for syscalls - malloc: preserve errno on mcheck hooks [BZ #17924] - x86 long double: Add tests for pseudo normal numbers - x86 long double: Consider pseudo numbers as signaling - io: Remove xmknod{at} implementations - io: Remove xstat implementations - free: preserve errno [BZ#17924] - hurd: Accept including hurd/version.h - hurd: Add WSTOPPED/WCONTINUED/WEXITED/WNOWAIT support [BZ #23091] - support: Make support_process_state_wait wait less - hurd: set sigaction for signal preemptors in arch-independent file - hurd: Fix spawni SPAWN_XFLAGS_TRY_SHELL with empty argv - hurd: Try shell in posix_spawn* only in compat mode - Remove _ISOMAC check from <cpu-features.h> - x86: Remove the duplicated CPU_FEATURE_CPU_P - Partially revert 681900d29683722b1cb0a8e565a0585846ec5a61 - x86 long double: Support pseudo numbers in isnanl - x86 long double: Support pseudo numbers in fpclassifyl - MTE: Do not pad size in realloc_check - tests-mcheck: New variable to run tests with MALLOC_CHECK_=3 - elf: Account for glibc-hwcaps/ prefix in _dl_important_hwcaps - misc: Use __ferror_unlocked instead of ferror - s390x: Regenerate ulps - powerpc: Regenerate ulps - addmntent: Remove unbounded alloca usage from getmntent [BZ#27083] - <sys/platform/x86.h>: Add Intel LAM support - i386: Regenerate ulps - aarch64: update ulps. - aarch64: Add aarch64-specific files for memory tagging support - aarch64: Add sysv specific enabling code for memory tagging - linux: Add compatibility definitions to sys/prctl.h for MTE - malloc: Basic support for memory tagging in the malloc() family - elf: Add a tunable to control use of tagged memory - config: Allow memory tagging to be enabled when configuring glibc - alpha: Remove anonymous union in struct stat [BZ #27042] - add inputs to auto-libm-test-in yielding larger errors (binary64, x86_64) - m68k: fix clobbering a5 in setjmp() [BZ #24202] - iconv add iconv_close before the function returned with bad value. - iconv: use iconv_close after iconv_open - Fix buffer overrun in EUC-KR conversion module (bz #24973) - hurd: Make trampoline fill siginfo ss_sp from sc_uesp - Hurd: make sigstates hold a reference on thread ports - profil-counter: Add missing SIGINFO case - hurd: implement SA_SIGINFO signal handlers. - hurd: Fix ELF_MACHINE_USER_ADDRESS_MASK value - hurd: Note when the vm_map kernel bug was fixed - hurd: Also turn KERN_INVALID_ADDRESS to EINVAL - ieee754: Remove unused __sin32 and __cos32 - ieee754: Remove slow paths from asin and acos - getenv: Move call to strlen to the branch it's used in. - Update kernel version to 5.10 in tst-mman-consts.py. - s390x: Require GCC 7.1 or later to build glibc. - malloc: Use __libc_initial to detect an inner libc - Replace __libc_multiple_libcs with __libc_initial flag - {nptl,htl}/semaphoreP.h: clean up - htl: Get sem_open/sem_close/sem_unlink support [BZ #25524] - pthread: Move semaphore initialization for open to semaphoreP.h - Mark __libc_freeres_fn as used [BZ #27002] - Update syscall lists for Linux 5.10. - htl: Add pshared semaphore support - hurd: Add LLL_PRIVATE and LLL_SHARED - hurd: Add __libc_open and __libc_close - htl: Add futex-internal.h - hurd: Add __lll_abstimed_wait_intr - hurd: make lll_* take a variable instead of a ptr - hurd: Rename LLL_INITIALIZER to LLL_LOCK_INITIALIZER - Use Linux 5.10 in build-many-glibcs.py.
94 lines
3.5 KiB
Diff
94 lines
3.5 KiB
Diff
Short description: fnmatch() fails with MBCS.
|
|
Author(s): Fedora glibc team <glibc@lists.fedoraproject.org>
|
|
Origin: PATCH
|
|
Bug-RHEL: #819430, #826149, #826151
|
|
Bug-Upstream: #14185
|
|
Upstream status: not-submitted
|
|
|
|
fnmatch() fails when '*' wildcard is applied on the file name
|
|
containing multi-byte character(s)
|
|
|
|
This needs to be reviewed thoroughly and go upstream with a
|
|
new test case.
|
|
|
|
|
|
diff --git a/posix/fnmatch.c b/posix/fnmatch.c
|
|
index 5896812c966ac7c6..63df3dae0911030f 100644
|
|
--- a/posix/fnmatch.c
|
|
+++ b/posix/fnmatch.c
|
|
@@ -237,6 +237,7 @@ fnmatch (const char *pattern, const char *string, int flags)
|
|
{
|
|
if (__glibc_unlikely (MB_CUR_MAX != 1))
|
|
{
|
|
+ const char *orig_pattern = pattern;
|
|
mbstate_t ps;
|
|
size_t n;
|
|
const char *p;
|
|
@@ -256,10 +257,8 @@ fnmatch (const char *pattern, const char *string, int flags)
|
|
alloca_used);
|
|
n = mbsrtowcs (wpattern, &p, n + 1, &ps);
|
|
if (__glibc_unlikely (n == (size_t) -1))
|
|
- /* Something wrong.
|
|
- XXX Do we have to set 'errno' to something which mbsrtows hasn't
|
|
- already done? */
|
|
- return -1;
|
|
+ /* Something wrong: Fall back to single byte matching. */
|
|
+ goto try_singlebyte;
|
|
if (p)
|
|
{
|
|
memset (&ps, '\0', sizeof (ps));
|
|
@@ -271,10 +270,8 @@ fnmatch (const char *pattern, const char *string, int flags)
|
|
prepare_wpattern:
|
|
n = mbsrtowcs (NULL, &pattern, 0, &ps);
|
|
if (__glibc_unlikely (n == (size_t) -1))
|
|
- /* Something wrong.
|
|
- XXX Do we have to set 'errno' to something which mbsrtows hasn't
|
|
- already done? */
|
|
- return -1;
|
|
+ /* Something wrong: Fall back to single byte matching. */
|
|
+ goto try_singlebyte;
|
|
if (__glibc_unlikely (n >= (size_t) -1 / sizeof (wchar_t)))
|
|
{
|
|
__set_errno (ENOMEM);
|
|
@@ -297,14 +294,8 @@ fnmatch (const char *pattern, const char *string, int flags)
|
|
alloca_used);
|
|
n = mbsrtowcs (wstring, &p, n + 1, &ps);
|
|
if (__glibc_unlikely (n == (size_t) -1))
|
|
- {
|
|
- /* Something wrong.
|
|
- XXX Do we have to set 'errno' to something which
|
|
- mbsrtows hasn't already done? */
|
|
- free_return:
|
|
- free (wpattern_malloc);
|
|
- return -1;
|
|
- }
|
|
+ /* Something wrong: Fall back to single byte matching. */
|
|
+ goto free_and_try_singlebyte;
|
|
if (p)
|
|
{
|
|
memset (&ps, '\0', sizeof (ps));
|
|
@@ -316,10 +307,8 @@ fnmatch (const char *pattern, const char *string, int flags)
|
|
prepare_wstring:
|
|
n = mbsrtowcs (NULL, &string, 0, &ps);
|
|
if (__glibc_unlikely (n == (size_t) -1))
|
|
- /* Something wrong.
|
|
- XXX Do we have to set 'errno' to something which mbsrtows hasn't
|
|
- already done? */
|
|
- goto free_return;
|
|
+ /* Something wrong: Fall back to singlebyte matching. */
|
|
+ goto free_and_try_singlebyte;
|
|
if (__glibc_unlikely (n >= (size_t) -1 / sizeof (wchar_t)))
|
|
{
|
|
free (wpattern_malloc);
|
|
@@ -346,6 +335,10 @@ fnmatch (const char *pattern, const char *string, int flags)
|
|
free (wpattern_malloc);
|
|
|
|
return res;
|
|
+ free_and_try_singlebyte:
|
|
+ free(wpattern_malloc);
|
|
+ try_singlebyte:
|
|
+ pattern = orig_pattern;
|
|
}
|
|
|
|
return internal_fnmatch (pattern, string, string + strlen (string),
|