This is the mail archive of the libc-alpha@sourceware.org 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]
Other format: [Raw text]

Re: [PATCH][TRY2] fix false multi-byte matches in some regular expressions


On Thu, Feb 16, 2012 at 2:39 PM, Stanislav Brabec <sbrabec@suse.cz> wrote:
> Roland McGrath wrote:
>> A change needs a ChangeLog entry, and it should mention the bugzilla
>> number. ?A subtle issue such as this warrants an addition to the test
>> suite.
>
> Here is the patch.
>
> I do not have a C language reproducer yet, just a command for sed using
> glibc regexp. See another branch of this thread.

I agree with Roland we really really need a test case for something as
complicated as this issue.

Please review: http://sourceware.org/glibc/wiki/Contribution%20checklist
* ChangeLog's should not be in the patch.
* ChangeLog is incorrectly formatted.

> commit 5b7a9f9f9471a4a8ff94d1919351a05bab6960c7
> Author: Stanislav Brabec <sbrabec@suse.cz>
> Date: ? Thu Feb 16 20:29:12 2012 +0100
>
> ? ?Fix miscomputation of remain_len in re_string_skip_chars() that may
> ? ?cause incomplete multi-byte character and false match. [BZ #13637]
>
> ? ?In the case of bug occurrence, __mbrtowc called from there returns -2
> ? ?(incomplete multi-byte character) on the concatenated string, which may
> ? ?cause false match in re_search().
>
> diff --git a/ChangeLog b/ChangeLog
> index 58d02d6..9e92b84 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,10 @@
> +2012-02-16 ?Stanislav Brabec ?<sbrabec@suse.cz>
> +
> + ? ? ? [BZ #13637]
> + ? ? ? * posix/regex_internal.c: Fix miscomputation of remain_len in

Should be:

\t* posix/regex_internal.c (re_string_skip_chars): [Terse explanation].

> + ? ? ? re_string_skip_chars() that may cause incomplete multi-byte
> + ? ? ? character and false match.
> +
> ?2012-02-16 ?Richard Henderson ?<rth@redhat.com>
>
> ? ? ? ?* sysdeps/s390/s390-32/crti.S, sysdeps/s390/s390-32/crtn.S: New files.
> diff --git a/posix/regex_internal.c b/posix/regex_internal.c
> index b71eae4..9be8a53 100644
> --- a/posix/regex_internal.c
> +++ b/posix/regex_internal.c
> @@ -499,7 +499,7 @@ re_string_skip_chars (re_string_t *pstr, int new_raw_idx, wint_t *last_wc)
> ? ? ? ?rawbuf_idx < new_raw_idx;)
> ? ? {
> ? ? ? wchar_t wc2;
> - ? ? ?int remain_len = pstr->len - rawbuf_idx;
> + ? ? ?int 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);
>
>
> --
> Best Regards / S pozdravem,
>
> Stanislav Brabec
> software developer
> ---------------------------------------------------------------------
> SUSE LINUX, s. r. o. ? ? ? ? ? ? ? ? ? ? ? ? ?e-mail: sbrabec@suse.cz
> Lihovarská 1060/12 ? ? ? ? ? ? ? ? ? ? ? ? ? ?tel: +49 911 7405384547
> 190 00 Praha 9 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?fax: +420 284 028 951
> Czech Republic ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?http://www.suse.cz/
>


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