commit 34e56ebeef6e7bdfbc134a49bf1773ee7a8bfcee
Author: Patsy Franklin <pfrankli(a)redhat.com>
Date: Wed May 30 17:29:53 2012 -0400
Resolves: sw#14185
-Fix fnmatch() fails when '*' wildcard is applied on the file name containing
multi-byte character(s)
glibc-rh819430.patch | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++
glibc.spec | 7 ++++-
2 files changed, 84 insertions(+), 1 deletions(-)
---
diff --git a/glibc-rh819430.patch b/glibc-rh819430.patch
new file mode 100644
index 0000000..8af1f78
--- /dev/null
+++ b/glibc-rh819430.patch
@@ -0,0 +1,78 @@
+diff -Nrup a/posix/fnmatch.c b/posix/fnmatch.c
+--- a/posix/fnmatch.c 2012-01-01 07:16:32.000000000 -0500
++++ b/posix/fnmatch.c 2012-05-23 14:14:29.099461189 -0400
+@@ -333,6 +333,7 @@ fnmatch (pattern, string, flags)
+ # if HANDLE_MULTIBYTE
+ if (__builtin_expect (MB_CUR_MAX, 1) != 1)
+ {
++ const char *orig_pattern = pattern;
+ mbstate_t ps;
+ size_t n;
+ const char *p;
+@@ -356,10 +357,8 @@ fnmatch (pattern, string, flags)
+ alloca_used);
+ n = mbsrtowcs (wpattern, &p, n + 1, &ps);
+ if (__builtin_expect (n == (size_t) -1, 0))
+- /* 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));
+@@ -371,10 +370,8 @@ fnmatch (pattern, string, flags)
+ prepare_wpattern:
+ n = mbsrtowcs (NULL, &pattern, 0, &ps);
+ if (__builtin_expect (n == (size_t) -1, 0))
+- /* 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 (__builtin_expect (n >= (size_t) -1 / sizeof (wchar_t), 0))
+ {
+ __set_errno (ENOMEM);
+@@ -401,14 +398,8 @@ fnmatch (pattern, string, flags)
+ alloca_used);
+ n = mbsrtowcs (wstring, &p, n + 1, &ps);
+ if (__builtin_expect (n == (size_t) -1, 0))
+- {
+- /* 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));
+@@ -420,10 +411,8 @@ fnmatch (pattern, string, flags)
+ prepare_wstring:
+ n = mbsrtowcs (NULL, &string, 0, &ps);
+ if (__builtin_expect (n == (size_t) -1, 0))
+- /* 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 (__builtin_expect (n >= (size_t) -1 / sizeof (wchar_t), 0))
+ {
+ free (wpattern_malloc);
+@@ -450,6 +439,10 @@ fnmatch (pattern, string, flags)
+ free (wpattern_malloc);
+
+ return res;
++ free_and_try_singlebyte:
++ free(wpattern_malloc);
++ try_singlebyte:
++ pattern = orig_pattern;
+ }
+ # endif /* mbstate_t and mbsrtowcs or _LIBC. */
+
diff --git a/glibc.spec b/glibc.spec
index c32fdbf..1b8408a 100644
--- a/glibc.spec
+++ b/glibc.spec
@@ -28,7 +28,7 @@
Summary: The GNU libc libraries
Name: glibc
Version: %{glibcversion}
-Release: 37%{?dist}
+Release: 38%{?dist}
# GPLv2+ is used in a bunch of programs, LGPLv2+ is used for libraries.
# Things that are linked directly into dynamically linked programs
# and shared libraries (e.g. crt files, lib*_nonshared.a) have an additional
@@ -114,6 +114,7 @@ Patch1046: %{name}-rh806403.patch
Patch1048: %{name}-rh804792.patch
Patch1052: %{name}-sw13979.patch
Patch1053: %{name}-rh817276.patch
+Patch1054: %{name}-rh819430.patch
#
# Patches submitted, but not yet approved upstream.
@@ -460,6 +461,7 @@ rm -rf %{glibcportsdir}
%patch2051 -p1
%patch1052 -p1
%patch2054 -p1
+%patch1054 -p1
pushd ../%{glibcportsdir}
%patch1053 -p1
@@ -1319,6 +1321,9 @@ rm -f *.filelist*
%endif
%changelog
+* Thu May 24 2012 Patsy Franklin <pfrankli(a)redhat.com> - 2.15-38
+ - Fix fnmatch() when '*' wildcard is applied on a file name containing
multibyte chars. (#819430)
+
* Thu May 10 2012 Jeff Law <law(a)redhat.com> - 2.15-37
- Try again to fix AVX testing (#801650)