Skip to content

Commit

Permalink
Extend the test for re-using pre-compiled regexp.
Browse files Browse the repository at this point in the history
A failure in compiling a regexp may lead to an inconsistent state, where the buffer is correctly populated, but the regexp pointer is NULL -> on next usage, the code will attempt to directly used (as the regexp buffer matches) the NULL pointer and crash.
Reported by Ben Newlin <Ben.Newlin@genesys.com>

(cherry picked from commit b77c182)
  • Loading branch information
bogdan-iancu committed Feb 28, 2018
1 parent b9641f6 commit e68044a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion transformations.c
Expand Up @@ -1704,7 +1704,8 @@ int tr_eval_re(struct sip_msg *msg, tr_param_t *tp, int subtype,
}
LM_DBG("Trying to apply regexp [%.*s] on : [%.*s]\n",
sv.len,sv.s,val->rs.len, val->rs.s);
if (!buf_re.s || buf_re.len != sv.len || memcmp(buf_re.s, sv.s, sv.len) != 0) {
if (subst_re==NULL || !buf_re.s || buf_re.len != sv.len ||
memcmp(buf_re.s, sv.s, sv.len) != 0) {
LM_DBG("we must compile the regexp\n");
if (subst_re != NULL) {
LM_DBG("freeing prev regexp\n");
Expand Down

0 comments on commit e68044a

Please sign in to comment.