about summary refs log tree commit diff
path: root/posix/fnmatch_loop.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-01-14 08:06:22 -0500
committerUlrich Drepper <drepper@gmail.com>2011-01-14 08:06:22 -0500
commit794c3ad3a405697e2663b00f616e319383b9bb7d (patch)
treeeabcf25257fdcc1e98cc3a9bf6a5333cba3dfb3c /posix/fnmatch_loop.c
parent68dc949774cb651d53541df4abdc60327f7e096b (diff)
downloadglibc-794c3ad3a405697e2663b00f616e319383b9bb7d.tar.gz
glibc-794c3ad3a405697e2663b00f616e319383b9bb7d.tar.xz
glibc-794c3ad3a405697e2663b00f616e319383b9bb7d.zip
FIx handling of unterminated [ expression in fnmatch.
Diffstat (limited to 'posix/fnmatch_loop.c')
-rw-r--r--posix/fnmatch_loop.c13
1 files changed, 10 insertions, 3 deletions
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;