From 794c3ad3a405697e2663b00f616e319383b9bb7d Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 14 Jan 2011 08:06:22 -0500 Subject: FIx handling of unterminated [ expression in fnmatch. --- posix/fnmatch_loop.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'posix/fnmatch_loop.c') diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c index 6b0224ea2c..5c15f46fd9 100644 --- a/posix/fnmatch_loop.c +++ b/posix/fnmatch_loop.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-1993,1996-2001,2003-2005,2007,2010 +/* Copyright (C) 1991-1993,1996-2001,2003-2005,2007,2010,2011 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -235,6 +235,8 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used) case L('['): { /* Nonzero if the sense of the character class is inverted. */ + CHAR *p_init = p; + CHAR *n_init = n; register int not; CHAR cold; UCHAR fn; @@ -445,8 +447,13 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used) } #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 { int is_range = 0; -- cgit 1.4.1