Blame SOURCES/glibc-rh757888.patch

b9ba6d
commit f3a6cc0a560a17f32a3e90d2f20501a53cab6058
b9ba6d
Author: Andreas Schwab <schwab@redhat.com>
b9ba6d
Date:   Tue Nov 29 10:52:22 2011 +0100
b9ba6d
b9ba6d
    Fix access after end of search string in regex matcher
b9ba6d
b9ba6d
diff --git a/locale/weight.h b/locale/weight.h
b9ba6d
index dc70a00..967e176 100644
b9ba6d
--- a/locale/weight.h
b9ba6d
+++ b/locale/weight.h
b9ba6d
@@ -1,4 +1,4 @@
b9ba6d
-/* Copyright (C) 1996,1997,1998,1999,2000,2003,2004 Free Software Foundation, Inc.
b9ba6d
+/* Copyright (C) 1996,1997,1998,1999,2000,2003,2004,2011 Free Software Foundation, Inc.
b9ba6d
    This file is part of the GNU C Library.
b9ba6d
    Written by Ulrich Drepper, <drepper@cygnus.com>.
b9ba6d
 
b9ba6d
@@ -20,7 +20,7 @@
b9ba6d
 /* Find index of weight.  */
b9ba6d
 auto inline int32_t
b9ba6d
 __attribute ((always_inline))
b9ba6d
-findidx (const unsigned char **cpp)
b9ba6d
+findidx (const unsigned char **cpp, size_t len)
b9ba6d
 {
b9ba6d
   int_fast32_t i = table[*(*cpp)++];
b9ba6d
   const unsigned char *cp;
b9ba6d
@@ -34,6 +34,7 @@ findidx (const unsigned char **cpp)
b9ba6d
      Search for the correct one.  */
b9ba6d
   cp = &extra[-i];
b9ba6d
   usrc = *cpp;
b9ba6d
+  --len;
b9ba6d
   while (1)
b9ba6d
     {
b9ba6d
       size_t nhere;
b9ba6d
@@ -56,7 +57,7 @@ findidx (const unsigned char **cpp)
b9ba6d
 	     already.  */
b9ba6d
 	  size_t cnt;
b9ba6d
 
b9ba6d
-	  for (cnt = 0; cnt < nhere; ++cnt)
b9ba6d
+	  for (cnt = 0; cnt < nhere && cnt < len; ++cnt)
b9ba6d
 	    if (cp[cnt] != usrc[cnt])
b9ba6d
 	      break;
b9ba6d
 
b9ba6d
@@ -79,13 +80,13 @@ findidx (const unsigned char **cpp)
b9ba6d
 	  size_t cnt;
b9ba6d
 	  size_t offset = 0;
b9ba6d
 
b9ba6d
-	  for (cnt = 0; cnt < nhere; ++cnt)
b9ba6d
+	  for (cnt = 0; cnt < nhere && cnt < len; ++cnt)
b9ba6d
 	    if (cp[cnt] != usrc[cnt])
b9ba6d
 	      break;
b9ba6d
 
b9ba6d
 	  if (cnt != nhere)
b9ba6d
 	    {
b9ba6d
-	      if (cp[cnt] > usrc[cnt])
b9ba6d
+	      if (cnt == len || cp[cnt] > usrc[cnt])
b9ba6d
 		{
b9ba6d
 		  /* Cannot be in this range.  */
b9ba6d
 		  cp += 2 * nhere;
b9ba6d
diff --git a/locale/weightwc.h b/locale/weightwc.h
b9ba6d
index 9ea1126..7862091 100644
b9ba6d
--- a/locale/weightwc.h
b9ba6d
+++ b/locale/weightwc.h
b9ba6d
@@ -1,4 +1,4 @@
b9ba6d
-/* Copyright (C) 1996-2001,2003,2004,2005,2007 Free Software Foundation, Inc.
b9ba6d
+/* Copyright (C) 1996-2001,2003,2004,2005,2007,2011 Free Software Foundation, Inc.
b9ba6d
    This file is part of the GNU C Library.
b9ba6d
    Written by Ulrich Drepper, <drepper@cygnus.com>.
b9ba6d
 
b9ba6d
@@ -20,7 +20,7 @@
b9ba6d
 /* Find index of weight.  */
b9ba6d
 auto inline int32_t
b9ba6d
 __attribute ((always_inline))
b9ba6d
-findidx (const wint_t **cpp)
b9ba6d
+findidx (const wint_t **cpp, size_t len)
b9ba6d
 {
b9ba6d
   wint_t ch = *(*cpp)++;
b9ba6d
   int32_t i = __collidx_table_lookup ((const char *) table, ch);
b9ba6d
@@ -32,6 +32,7 @@ findidx (const wint_t **cpp)
b9ba6d
   /* Oh well, more than one sequence starting with this byte.
b9ba6d
      Search for the correct one.  */
b9ba6d
   const int32_t *cp = (const int32_t *) &extra[-i];
b9ba6d
+  --len;
b9ba6d
   while (1)
b9ba6d
     {
b9ba6d
       size_t nhere;
b9ba6d
@@ -54,7 +55,7 @@ findidx (const wint_t **cpp)
b9ba6d
 	     already.  */
b9ba6d
 	  size_t cnt;
b9ba6d
 
b9ba6d
-	  for (cnt = 0; cnt < nhere; ++cnt)
b9ba6d
+	  for (cnt = 0; cnt < nhere && cnt < len; ++cnt)
b9ba6d
 	    if (cp[cnt] != usrc[cnt])
b9ba6d
 	      break;
b9ba6d
 
b9ba6d
@@ -75,7 +76,7 @@ findidx (const wint_t **cpp)
b9ba6d
 	  size_t cnt;
b9ba6d
 	  size_t offset;
b9ba6d
 
b9ba6d
-	  for (cnt = 0; cnt < nhere - 1; ++cnt)
b9ba6d
+	  for (cnt = 0; cnt < nhere - 1 && cnt < len; ++cnt)
b9ba6d
 	    if (cp[cnt] != usrc[cnt])
b9ba6d
 	      break;
b9ba6d
 
b9ba6d
diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c
b9ba6d
index 18a6667..72bd3ee 100644
b9ba6d
--- a/posix/fnmatch_loop.c
b9ba6d
+++ b/posix/fnmatch_loop.c
b9ba6d
@@ -412,7 +412,7 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
b9ba6d
 			  _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
b9ba6d
 # endif
b9ba6d
 
b9ba6d
-			idx = findidx (&cp;;
b9ba6d
+			idx = findidx (&cp, 1);
b9ba6d
 			if (idx != 0)
b9ba6d
 			  {
b9ba6d
 			    /* We found a table entry.  Now see whether the
b9ba6d
@@ -422,7 +422,7 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
b9ba6d
 			    int32_t idx2;
b9ba6d
 			    const UCHAR *np = (const UCHAR *) n;
b9ba6d
 
b9ba6d
-			    idx2 = findidx (&np);
b9ba6d
+			    idx2 = findidx (&np, string_end - n);
b9ba6d
 			    if (idx2 != 0
b9ba6d
 				&& (idx >> 24) == (idx2 >> 24)
b9ba6d
 				&& len == weights[idx2 & 0xffffff])
b9ba6d
diff --git a/posix/regcomp.c b/posix/regcomp.c
b9ba6d
index b238c08..34ee845 100644
b9ba6d
--- a/posix/regcomp.c
b9ba6d
+++ b/posix/regcomp.c
b9ba6d
@@ -1,5 +1,5 @@
b9ba6d
 /* Extended regular expression matching and search library.
b9ba6d
-   Copyright (C) 2002-2007,2009,2010 Free Software Foundation, Inc.
b9ba6d
+   Copyright (C) 2002-2007,2009,2010,2011 Free Software Foundation, Inc.
b9ba6d
    This file is part of the GNU C Library.
b9ba6d
    Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
b9ba6d
 
b9ba6d
@@ -3409,19 +3409,18 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
b9ba6d
 						   _NL_COLLATE_EXTRAMB);
b9ba6d
       indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
b9ba6d
 						_NL_COLLATE_INDIRECTMB);
b9ba6d
-      idx1 = findidx (&cp;;
b9ba6d
-      if (BE (idx1 == 0 || cp < name + strlen ((const char *) name), 0))
b9ba6d
+      idx1 = findidx (&cp, -1);
b9ba6d
+      if (BE (idx1 == 0 || *cp != '\0', 0))
b9ba6d
 	/* This isn't a valid character.  */
b9ba6d
 	return REG_ECOLLATE;
b9ba6d
 
b9ba6d
       /* Build single byte matcing table for this equivalence class.  */
b9ba6d
-      char_buf[1] = (unsigned char) '\0';
b9ba6d
       len = weights[idx1 & 0xffffff];
b9ba6d
       for (ch = 0; ch < SBC_MAX; ++ch)
b9ba6d
 	{
b9ba6d
 	  char_buf[0] = ch;
b9ba6d
 	  cp = char_buf;
b9ba6d
-	  idx2 = findidx (&cp;;
b9ba6d
+	  idx2 = findidx (&cp, 1);
b9ba6d
 /*
b9ba6d
 	  idx2 = table[ch];
b9ba6d
 */
b9ba6d
b9ba6d
--- a/posix/regex_internal.h	2011-11-30 12:47:02.706567482 -0700
b9ba6d
+++ a/posix/regex_internal.h	2011-11-30 12:47:32.969558337 -0700
b9ba6d
@@ -756,7 +756,7 @@
b9ba6d
       indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
b9ba6d
 						_NL_COLLATE_INDIRECTMB);
b9ba6d
       p = pstr->mbs + idx;
b9ba6d
-      tmp = findidx (&p);
b9ba6d
+      tmp = findidx (&p, pstr->len - idx);
b9ba6d
       return p - pstr->mbs - idx;
b9ba6d
     }
b9ba6d
   else
b9ba6d
diff --git a/posix/regexec.c b/posix/regexec.c
b9ba6d
index 9e0c565..3ea810b 100644
b9ba6d
--- a/posix/regexec.c
b9ba6d
+++ b/posix/regexec.c
b9ba6d
@@ -3924,7 +3924,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, int node_idx,
b9ba6d
 		_NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
b9ba6d
 	      indirect = (const int32_t *)
b9ba6d
 		_NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
b9ba6d
-	      int32_t idx = findidx (&cp;;
b9ba6d
+	      int32_t idx = findidx (&cp, elem_len);
b9ba6d
 	      if (idx > 0)
b9ba6d
 		for (i = 0; i < cset->nequiv_classes; ++i)
b9ba6d
 		  {
b9ba6d
diff --git a/string/strcoll_l.c b/string/strcoll_l.c
b9ba6d
index d8d1139..fb77d08 100644
b9ba6d
--- a/string/strcoll_l.c
b9ba6d
+++ b/string/strcoll_l.c
b9ba6d
@@ -1,4 +1,4 @@
b9ba6d
-/* Copyright (C) 1995-1997,2002,2004,2007,2010 Free Software Foundation, Inc.
b9ba6d
+/* Copyright (C) 1995-1997,2002,2004,2007,2010,2011 Free Software Foundation, Inc.
b9ba6d
    This file is part of the GNU C Library.
b9ba6d
    Written by Ulrich Drepper <drepper@gnu.org>, 1995.
b9ba6d
 
b9ba6d
@@ -205,7 +205,7 @@ STRCOLL (s1, s2, l)
b9ba6d
 
b9ba6d
 		while (*us1 != L('\0'))
b9ba6d
 		  {
b9ba6d
-		    int32_t tmp = findidx (&us1;;
b9ba6d
+		    int32_t tmp = findidx (&us1, -1);
b9ba6d
 		    rule1arr[idx1max] = tmp >> 24;
b9ba6d
 		    idx1arr[idx1max] = tmp & 0xffffff;
b9ba6d
 		    idx1cnt = idx1max++;
b9ba6d
@@ -267,7 +267,7 @@ STRCOLL (s1, s2, l)
b9ba6d
 
b9ba6d
 		while (*us2 != L('\0'))
b9ba6d
 		  {
b9ba6d
-		    int32_t tmp = findidx (&us2;;
b9ba6d
+		    int32_t tmp = findidx (&us2, -1);
b9ba6d
 		    rule2arr[idx2max] = tmp >> 24;
b9ba6d
 		    idx2arr[idx2max] = tmp & 0xffffff;
b9ba6d
 		    idx2cnt = idx2max++;
b9ba6d
diff --git a/string/strxfrm_l.c b/string/strxfrm_l.c
b9ba6d
index 220253c..b06556d 100644
b9ba6d
--- a/string/strxfrm_l.c
b9ba6d
+++ b/string/strxfrm_l.c
b9ba6d
@@ -176,7 +176,7 @@ STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n, __locale_t l)
b9ba6d
   idxmax = 0;
b9ba6d
   do
b9ba6d
     {
b9ba6d
-      int32_t tmp = findidx (&usrc);
b9ba6d
+      int32_t tmp = findidx (&usrc, -1);
b9ba6d
       rulearr[idxmax] = tmp >> 24;
b9ba6d
       idxarr[idxmax] = tmp & 0xffffff;
b9ba6d