[13/17] Regex: Use btowc when checking for accepting bytes.

Message ID 201712080916.vB89GxoH005515@skeeve.com
State New, archived
Headers

Commit Message

Arnold Robbins Dec. 8, 2017, 9:16 a.m. UTC
  This patch uses btowc to validate values that are less than SBC_MAX.

2017-11-30         Arnold D. Robbins     <arnold@skeeve.com>

	* posix/regexec.c (check_node_accept_bytes): Use btowc
	for values less than SBC_MAX.
  

Patch

diff --git a/posix/regexec.c b/posix/regexec.c
index f14685a..dcdd33b 100644
--- a/posix/regexec.c
+++ b/posix/regexec.c
@@ -3686,6 +3686,7 @@  check_node_accept_bytes (const re_dfa_t *dfa, int node_idx,
   const re_token_t *node = dfa->nodes + node_idx;
   int char_len, elem_len;
   int i;
+  wint_t wc;
 
   if (BE (node->type == OP_UTF8_PERIOD, 0))
     {
@@ -3755,7 +3756,8 @@  check_node_accept_bytes (const re_dfa_t *dfa, int node_idx,
     }
 
   elem_len = re_string_elem_size_at (input, str_idx);
-  if ((elem_len <= 1 && char_len <= 1) || char_len == 0)
+  wc = __btowc(*(input->mbs+str_idx));
+  if (((elem_len <= 1 && char_len <= 1) || char_len == 0) && (wc != WEOF && wc < SBC_MAX))
     return 0;
 
   if (node->type == COMPLEX_BRACKET)