From 569f41015cbba5b185dc1e4655c801fb61302d10 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 30 Dec 2012 00:10:51 -0800 Subject: [PATCH] regex: check that pattern char is single-byte Reported by Aharon Robbins in . * lib/regexec.c (check_node_accept_bytes): Return 0 if the pattern string has a multibyte character here. --- ChangeLog | 6 ++++++ lib/regexec.c | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8c61adb680..0c3c7f12ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2012-12-29 Paul Eggert + regex: check that pattern char is single-byte + Reported by Aharon Robbins in + . + * lib/regexec.c (check_node_accept_bytes): + Return 0 if the pattern string has a multibyte character here. + regex: implement rational ranges Reported by Aharon Robbins in . diff --git a/lib/regexec.c b/lib/regexec.c index 22e8dd67c4..b10efb3a93 100644 --- a/lib/regexec.c +++ b/lib/regexec.c @@ -3858,7 +3858,11 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, elem_len = re_string_elem_size_at (input, str_idx); if ((elem_len <= 1 && char_len <= 1) || char_len == 0) - return 0; + { + wint_t wc = __btowc (input->mbs[str_idx]); + if (wc < SBC_MAX && wc != WEOF) + return 0; + } if (node->type == COMPLEX_BRACKET) { -- 2.39.5