changeset 16387:53295e65981f

regex: fix false multibyte matches in some regular expressions See <http://sourceware.org/bugzilla/show_bug.cgi?id=13637> and <http://sourceware.org/ml/libc-alpha/2012-02/msg00521.html>. * lib/regex_internal.c (re_string_skip_chars): Fix miscomputation of remain_len that may cause incomplete multi-byte character and false match.
author Stanislav Brabec <sbrabec@suse.cz>
date Fri, 24 Feb 2012 12:24:44 -0800
parents bb8c8cc1050d
children d0e332889b10
files ChangeLog lib/regex_internal.c
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-02-24  Stanislav Brabec  <sbrabec@suse.cz>  (tiny change)
+
+	regex: fix false multibyte matches in some regular expressions
+	See <http://sourceware.org/bugzilla/show_bug.cgi?id=13637>
+	and <http://sourceware.org/ml/libc-alpha/2012-02/msg00521.html>.
+	* lib/regex_internal.c (re_string_skip_chars):
+	Fix miscomputation of remain_len that may cause incomplete
+	multi-byte character and false match.
+
 2012-02-24  Jim Meyering  <meyering@redhat.com>
 
 	maint.mk: tell sc_prohibit_strcmp to ding "0 == strcmp (...)", too
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -498,7 +498,7 @@
        rawbuf_idx < new_raw_idx;)
     {
       wchar_t wc2;
-      Idx remain_len = pstr->len - rawbuf_idx;
+      Idx remain_len = pstr->raw_len - rawbuf_idx;
       prev_st = pstr->cur_state;
       mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx,
 			  remain_len, &pstr->cur_state);