Blame SOURCES/glibc-fedora-regcomp-sw11561.patch

00db10
Upstream commit:
00db10
00db10
commit 7e2f0d2d77e4bc273fe00f99d970605d8e38d4d6
00db10
Author: Andreas Schwab <schwab@suse.de>
00db10
Date:   Mon Feb 4 10:16:33 2013 +0100
00db10
00db10
    Fix handling of collating symbols in regexps
00db10
00db10
From c1b97d6d896b1f22fdf5d28471ef7859ec840a57 Mon Sep 17 00:00:00 2001
00db10
From: Andreas Schwab <schwab@redhat.com>
00db10
Date: Wed, 1 Sep 2010 17:26:15 +0200
00db10
Subject: [PATCH] Fix handling of collating symbols in regexps
00db10
00db10
[BZ #11561]
00db10
* posix/regcomp.c (parse_bracket_exp): When looking up collating
00db10
elements compare against the byte sequence of it, not its name.
00db10
00db10
---
00db10
 ChangeLog       |    4 +++
00db10
 posix/regcomp.c |   72 ++++++++++++++++++++----------------------------------
00db10
 2 files changed, 31 insertions(+), 45 deletions(-)
00db10
00db10
--- glibc-2.17-c758a686/posix/regcomp.c
00db10
+++ glibc-2.17-c758a686/posix/regcomp.c
00db10
@@ -2772,40 +2772,29 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
00db10
 
00db10
   /* Local function for parse_bracket_exp used in _LIBC environement.
00db10
      Seek the collating symbol entry correspondings to NAME.
00db10
-     Return the index of the symbol in the SYMB_TABLE.  */
00db10
+     Return the index of the symbol in the SYMB_TABLE,
00db10
+     or -1 if not found.  */
00db10
 
00db10
   auto inline int32_t
00db10
   __attribute ((always_inline))
00db10
-  seek_collating_symbol_entry (name, name_len)
00db10
-	 const unsigned char *name;
00db10
-	 size_t name_len;
00db10
+  seek_collating_symbol_entry (const unsigned char *name, size_t name_len)
00db10
     {
00db10
-      int32_t hash = elem_hash ((const char *) name, name_len);
00db10
-      int32_t elem = hash % table_size;
00db10
-      if (symb_table[2 * elem] != 0)
00db10
-	{
00db10
-	  int32_t second = hash % (table_size - 2) + 1;
00db10
-
00db10
-	  do
00db10
-	    {
00db10
-	      /* First compare the hashing value.  */
00db10
-	      if (symb_table[2 * elem] == hash
00db10
-		  /* Compare the length of the name.  */
00db10
-		  && name_len == extra[symb_table[2 * elem + 1]]
00db10
-		  /* Compare the name.  */
00db10
-		  && memcmp (name, &extra[symb_table[2 * elem + 1] + 1],
00db10
-			     name_len) == 0)
00db10
-		{
00db10
-		  /* Yep, this is the entry.  */
00db10
-		  break;
00db10
-		}
00db10
+      int32_t elem;
00db10
 
00db10
-	      /* Next entry.  */
00db10
-	      elem += second;
00db10
-	    }
00db10
-	  while (symb_table[2 * elem] != 0);
00db10
-	}
00db10
-      return elem;
00db10
+      for (elem = 0; elem < table_size; elem++)
00db10
+	if (symb_table[2 * elem] != 0)
00db10
+	  {
00db10
+	    int32_t idx = symb_table[2 * elem + 1];
00db10
+	    /* Skip the name of collating element name.  */
00db10
+	    idx += 1 + extra[idx];
00db10
+	    if (/* Compare the length of the name.  */
00db10
+		name_len == extra[idx]
00db10
+		/* Compare the name.  */
00db10
+		&& memcmp (name, &extra[idx + 1], name_len) == 0)
00db10
+	      /* Yep, this is the entry.  */
00db10
+	      return elem;
00db10
+	  }
00db10
+      return -1;
00db10
     }
00db10
 
00db10
   /* Local function for parse_bracket_exp used in _LIBC environment.
00db10
@@ -2814,8 +2803,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
00db10
 
00db10
   auto inline unsigned int
00db10
   __attribute ((always_inline))
00db10
-  lookup_collation_sequence_value (br_elem)
00db10
-	 bracket_elem_t *br_elem;
00db10
+  lookup_collation_sequence_value (bracket_elem_t *br_elem)
00db10
     {
00db10
       if (br_elem->type == SB_CHAR)
00db10
 	{
00db10
@@ -2843,7 +2831,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
00db10
 	      int32_t elem, idx;
00db10
 	      elem = seek_collating_symbol_entry (br_elem->opr.name,
00db10
 						  sym_name_len);
00db10
-	      if (symb_table[2 * elem] != 0)
00db10
+	      if (elem != -1)
00db10
 		{
00db10
 		  /* We found the entry.  */
00db10
 		  idx = symb_table[2 * elem + 1];
00db10
@@ -2861,7 +2849,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
00db10
 		  /* Return the collation sequence value.  */
00db10
 		  return *(unsigned int *) (extra + idx);
00db10
 		}
00db10
-	      else if (symb_table[2 * elem] == 0 && sym_name_len == 1)
00db10
+	      else if (sym_name_len == 1)
00db10
 		{
00db10
 		  /* No valid character.  Match it as a single byte
00db10
 		     character.  */
00db10
@@ -2883,11 +2871,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
00db10
 
00db10
   auto inline reg_errcode_t
00db10
   __attribute ((always_inline))
00db10
-  build_range_exp (sbcset, mbcset, range_alloc, start_elem, end_elem)
00db10
-	 re_charset_t *mbcset;
00db10
-	 int *range_alloc;
00db10
-	 bitset_t sbcset;
00db10
-	 bracket_elem_t *start_elem, *end_elem;
00db10
+  build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc,
00db10
+		   bracket_elem_t *start_elem, bracket_elem_t *end_elem)
00db10
     {
00db10
       unsigned int ch;
00db10
       uint32_t start_collseq;
00db10
@@ -2966,25 +2951,22 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
00db10
 
00db10
   auto inline reg_errcode_t
00db10
   __attribute ((always_inline))
00db10
-  build_collating_symbol (sbcset, mbcset, coll_sym_alloc, name)
00db10
-	 re_charset_t *mbcset;
00db10
-	 int *coll_sym_alloc;
00db10
-	 bitset_t sbcset;
00db10
-	 const unsigned char *name;
00db10
+  build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
00db10
+			  int *coll_sym_alloc, const unsigned char *name)
00db10
     {
00db10
       int32_t elem, idx;
00db10
       size_t name_len = strlen ((const char *) name);
00db10
       if (nrules != 0)
00db10
 	{
00db10
 	  elem = seek_collating_symbol_entry (name, name_len);
00db10
-	  if (symb_table[2 * elem] != 0)
00db10
+	  if (elem != -1)
00db10
 	    {
00db10
 	      /* We found the entry.  */
00db10
 	      idx = symb_table[2 * elem + 1];
00db10
 	      /* Skip the name of collating element name.  */
00db10
 	      idx += 1 + extra[idx];
00db10
 	    }
00db10
-	  else if (symb_table[2 * elem] == 0 && name_len == 1)
00db10
+	  else if (name_len == 1)
00db10
 	    {
00db10
 	      /* No valid character, treat it as a normal
00db10
 		 character.  */