[13/17] Regex: Use btowc when checking for accepting bytes.
Commit Message
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.
@@ -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)