From patchwork Fri Dec 8 09:16:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnold Robbins X-Patchwork-Id: 24804 Received: (qmail 101428 invoked by alias); 8 Dec 2017 09:21:53 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 101302 invoked by uid 89); 8 Dec 2017 09:21:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, MANY_HDRS_LCASE, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=HContent-type:text, Hx-spam-relays-external:ESMTPA X-HELO: mxout4.netvision.net.il MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII From: Arnold Robbins Message-id: <201712080916.vB89GxoH005515@skeeve.com> Date: Fri, 08 Dec 2017 11:16:59 +0200 To: carlos@redhat.com, libc-alpha@sourceware.org Subject: [PATCH 13/17] Regex: Use btowc when checking for accepting bytes. User-Agent: Heirloom mailx 12.5 6/20/10 This patch uses btowc to validate values that are less than SBC_MAX. 2017-11-30 Arnold D. Robbins * posix/regexec.c (check_node_accept_bytes): Use btowc for values less than SBC_MAX. 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)