diff options
author | JinWang An <jinwang.an@samsung.com> | 2021-02-25 13:25:50 +0900 |
---|---|---|
committer | JinWang An <jinwang.an@samsung.com> | 2021-02-25 13:25:50 +0900 |
commit | c35b28d627d4804963e084bdd051993064cb25d7 (patch) | |
tree | 12d9ecacd919bb93796b4aaffb4fd99a6b98ca26 | |
parent | 875a98baebfca49e1ecdad28562ccaa2e57e9b3a (diff) | |
download | m4-accepted/tizen_6.5_base.tar.gz m4-accepted/tizen_6.5_base.tar.bz2 m4-accepted/tizen_6.5_base.zip |
[CVE-2009-5155] Diagnose ERE '()|\1'tizen_6.5.m2_releasesubmit/tizen_base/20210225.050823submit/tizen_6.5_base/20211027.200801submit/tizen_6.5_base/20211027.183101submit/tizen_6.5_base/20211026.180901accepted/tizen/base/tool/20210301.230508accepted/tizen/6.5/base/tool/20211027.120238accepted/tizen/6.5/base/20230714.002603tizen_6.5_basebackup/m4-1.4.17-20211230accepted/tizen_6.5_base_toolaccepted/tizen_6.5_base
Problem reported by Hanno Böck in: http://bugs.gnu.org/21513
* lib/regcomp.c (parse_reg_exp): While parsing alternatives, keep
track of the set of previously-completed subexpressions available
before the first alternative, and restore this set just before
parsing each subsequent alternative. This lets us diagnose the
invalid back-reference in the ERE '()|\1'.
Change-Id: I6de4f8c79837656f670b5c34a0869619af198abe
Signed-off-by: JinWang An <jinwang.an@samsung.com>
-rw-r--r-- | lib/regcomp.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/regcomp.c b/lib/regcomp.c index f0b2e52..6b7c105 100644 --- a/lib/regcomp.c +++ b/lib/regcomp.c @@ -2187,6 +2187,7 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, { re_dfa_t *dfa = preg->buffer; bin_tree_t *tree, *branch = NULL; + bitset_word_t initial_bkref_map = dfa->completed_bkref_map; tree = parse_branch (regexp, preg, token, syntax, nest, err); if (BE (*err != REG_NOERROR && tree == NULL, 0)) return NULL; @@ -2197,9 +2198,16 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, if (token->type != OP_ALT && token->type != END_OF_RE && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) { + bitset_word_t accumulated_bkref_map = dfa->completed_bkref_map; + dfa->completed_bkref_map = initial_bkref_map; branch = parse_branch (regexp, preg, token, syntax, nest, err); if (BE (*err != REG_NOERROR && branch == NULL, 0)) + { + if (tree != NULL) + postorder (tree, free_tree, NULL); return NULL; + } + dfa->completed_bkref_map |= accumulated_bkref_map; } else branch = NULL; |