From 0bc30ce602212b9005e296602081138448691e79 Mon Sep 17 00:00:00 2001 From: James Youngman Date: Thu, 12 May 2011 22:14:11 +0100 Subject: [PATCH] fnmatch: sync glibc change fixing Bugzilla bug #12378 * lib/fnmatch_loop.c (FCT): When matching '[' keep track of beginning and fall back to matching as normal character if the string ends before the matching ']' is found. This is what POSIX requires. --- ChangeLog | 8 ++++++++ lib/fnmatch_loop.c | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1745185d0..f5e33cb249 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-05-11 Ulrich Drepper + + Sync glibc change fixing Bugzilla bug #12378. + * lib/fnmatch_loop.c (FCT): When matching '[' keep track of + beginning and fall back to matching as normal character if the + string ends before the matching ']' is found. This is what POSIX + requires. + 2011-05-13 Eric Blake getcwd-lgpl: relax test for FreeBSD diff --git a/lib/fnmatch_loop.c b/lib/fnmatch_loop.c index ed760dd8af..1fb246f0a2 100644 --- a/lib/fnmatch_loop.c +++ b/lib/fnmatch_loop.c @@ -200,6 +200,8 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, case L_('['): { /* Nonzero if the sense of the character class is inverted. */ + CHAR *p_init = p; + CHAR *n_init = n; register bool not; CHAR cold; UCHAR fn; @@ -410,8 +412,13 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, } #endif else if (c == L_('\0')) - /* [ (unterminated) loses. */ - return FNM_NOMATCH; + { + /* [ unterminated, treat as normal character. */ + p = p_init; + n = n_init; + c = L_('['); + goto normal_match; + } else { bool is_range = false; -- 2.30.2