bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 6/6] regex: check that pattern char is single-byte


From: Paul Eggert
Subject: [PATCH 6/6] regex: check that pattern char is single-byte
Date: Sun, 30 Dec 2012 00:17:24 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

Reported by Aharon Robbins in
<http://sourceware.org/ml/libc-alpha/2012-12/msg00456.html>.
* 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 8c61adb..0c3c7f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2012-12-29  Paul Eggert  <address@hidden>
 
+       regex: check that pattern char is single-byte
+       Reported by Aharon Robbins in
+       <http://sourceware.org/ml/libc-alpha/2012-12/msg00456.html>.
+       * 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
        <http://sourceware.org/ml/libc-alpha/2012-12/msg00456.html>.
diff --git a/lib/regexec.c b/lib/regexec.c
index 22e8dd6..b10efb3 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)
     {
-- 
1.7.11.7




reply via email to

[Prev in Thread] Current Thread [Next in Thread]