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]

[patch] regex bug fix.


Hello,

Following test program will coredump if link with Electric Fence.
(Thanks Rodrigo Barbosa <rodrigob@conectiva.com.br>, he let me know
 the problem.)

g++ -o crash crash.cc -lefence
=======
#include <sys/types.h>
#include <regex.h>
#include <string>

string some_staticaly_stanciated_object;

main ()
{
	regex_t p;

	regcomp(&p,"kernel",p);
}
=======

Then, the following patch can fix it, I think.
(I'm sorry, since I haven't gotten 2.2.3pre1 yet by temporary network problem,
 this patch is against 2.2.2.)

2001-03-29  Isamu Hasegawa  <isamu@yamato.ibm.com>

	* posix/regex.c: fix typo and add a sentinel.


--- posix/regex.c.2.2.2	Fri Feb 16 14:49:59 2001
+++ posix/regex.c	Thu Mar 29 13:48:36 2001
@@ -65,7 +65,7 @@
 # define CHAR_CLASS_SIZE ((__alignof__(wctype_t)+sizeof(wctype_t))/sizeof(CHAR_TYPE)+1)
 # define PUT_CHAR(c) \
   do {									      \
-    if (MC_CUR_MAX == 1)						      \
+    if (MB_CUR_MAX == 1)						      \
       putchar (c);							      \
     else								      \
       printf ("%C", (wint_t) c); /* Should we use wide stream??  */	      \
@@ -2346,7 +2346,8 @@ regex_compile (pattern, size, syntax, bu
 
 #ifdef MBS_SUPPORT
   /* Initialize the wchar_t PATTERN and offset_buffer.  */
-  p = pend = pattern = TALLOC(csize, CHAR_TYPE);
+  p = pend = pattern = TALLOC(csize + 1, CHAR_TYPE);
+  p[csize] = L'\0';	/* sentinel */
   mbs_offset = TALLOC(csize + 1, int);
   is_binary = TALLOC(csize + 1, char);
   if (pattern == NULL || mbs_offset == NULL || is_binary == NULL)


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