This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: regex.c is not 64bit clean


Ulrich Drepper <drepper@redhat.com> wrote:
> code: you are storing a pointer in the wchar_t array.

I'm ashamed of such a stupid bug...
How about the following patch?

However I fear that my assumption might be incorrect.
I think the index of the _NL_COLLATE_SYMB_EXTRAMB table is
not more than wchar_t.  Is this assumption true?

Thanks,
--
Isamu Hasegawa
IBM Japan, Ltd.

--- regex.c.bug	Wed Feb  7 10:57:30 2001
+++ regex.c	Wed Feb  7 11:17:37 2001
@@ -2991,7 +2991,7 @@
 				    /* Adjust for the alignment.  */
 				    idx = (idx + 3) & ~4;
 
-				    str[0] = (wchar_t) &extra[idx + 4];
+				    str[0] = (wchar_t) idx + 4;
 				  }
 				else if (symb_table[2 * elem] == 0 && c1 == 1)
 				  {
@@ -4397,13 +4397,15 @@
     {
       const char *collseq = (const char *) _NL_CURRENT(LC_COLLATE,
 						       _NL_COLLATE_COLLSEQWC);
+      const unsigned char *extra = (const unsigned char *)
+	_NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
 
       if (range_start_char < -1)
 	{
 	  /* range_start is a collating symbol.  */
 	  int32_t *wextra;
 	  /* Retreive the index and get collation sequence value.  */
-	  wextra = (int32_t*)char_set[-range_start_char];
+	  wextra = (int32_t*)(extra + char_set[-range_start_char]);
 	  start_val = wextra[1 + *wextra];
 	}
       else
@@ -6001,11 +6003,14 @@
 # ifdef _LIBC
 	    if (nrules != 0)
 	      {
+		const unsigned char *extra = (const unsigned char *)
+		  _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
+
 		for (workp2 = workp + coll_symbol_length ; workp < workp2 ;
 		     workp++)
 		  {
 		    int32_t *wextra;
-		    wextra = (int32_t*) *workp++;
+		    wextra = (int32_t*)(extra + *workp++);
 		    for (i = 0; i < *wextra; ++i)
 		      if (TRANSLATE(d[i]) != wextra[1 + i])
 			break;
@@ -6125,7 +6130,7 @@
 
 		/* Update d, however d will be incremented at
 		   char_set_matched:, we decrement d here.  */
-		d = backup_d + (wint_t)cp - (wint_t)str_buf - 1;
+		d = backup_d + ((uintptr_t)cp - (uintptr_t)str_buf - 1);
 		if (d >= dend)
 		  {
 		    if (dend == end_match_2)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]