Fix fnmatch() when '*' wildcard is applied on a file name containing multibyte chars. (#819430/14185)
This commit is contained in:
parent
e1b411d16d
commit
200aebfe55
78
glibc-rh819430.patch
Normal file
78
glibc-rh819430.patch
Normal file
@ -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. */
|
||||
|
@ -28,7 +28,7 @@
|
||||
Summary: The GNU libc libraries
|
||||
Name: glibc
|
||||
Version: %{glibcversion}
|
||||
Release: 5%{?dist}
|
||||
Release: 6%{?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
|
||||
@ -170,6 +170,9 @@ Patch2033: %{name}-rh788989-2.patch
|
||||
# Upstream BZ 13027
|
||||
Patch2034: %{name}-rh804630.patch
|
||||
|
||||
# Upstream BZ 14185
|
||||
Patch2035: %{name}-rh819430.patch
|
||||
|
||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
Obsoletes: glibc-profile < 2.4
|
||||
Obsoletes: nss_db
|
||||
@ -419,6 +422,7 @@ rm -rf %{glibcportsdir}
|
||||
%patch2033 -p1
|
||||
%patch2034 -p1
|
||||
%patch0035 -p1
|
||||
%patch2035 -p1
|
||||
|
||||
# A lot of programs still misuse memcpy when they have to use
|
||||
# memmove. The memcpy implementation below is not tolerant at
|
||||
@ -1295,6 +1299,9 @@ rm -f *.filelist*
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Thu May 31 2012 Patsy Franklin <patsy@redhat.com> - 2.15.90-6
|
||||
- Fix fnmatch() when '*' wildcard is applied on a file name containing multibyte chars. (#819430)
|
||||
|
||||
* Wed May 30 2012 Jeff Law <law@redhat.com> - 2.15.90-5
|
||||
- Resync with upstream sources.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user