Module: kamailio
Branch: master
Commit: 4763773eddf5e0e5ea4ae35ee6c2002e05f8bd9d
URL:
https://github.com/kamailio/kamailio/commit/4763773eddf5e0e5ea4ae35ee6c2002…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2015-01-14T11:29:51+01:00
dialplan: skip check subexpressions on expressions with pvs
---
Modified: modules/dialplan/dp_db.c
Modified: modules/dialplan/dp_repl.c
---
Diff:
https://github.com/kamailio/kamailio/commit/4763773eddf5e0e5ea4ae35ee6c2002…
Patch:
https://github.com/kamailio/kamailio/commit/4763773eddf5e0e5ea4ae35ee6c2002…
---
diff --git a/modules/dialplan/dp_db.c b/modules/dialplan/dp_db.c
index 57b0e76..c1c421d 100644
--- a/modules/dialplan/dp_db.c
+++ b/modules/dialplan/dp_db.c
@@ -494,8 +494,10 @@ dpl_node_t * build_rule(db_val_t * values)
LM_DBG("building rule for [%d:%.*s/%.*s/%.*s]\n", matchop,
match_exp.len, ZSW(match_exp.s), subst_exp.len, ZSW(subst_exp.s),
repl_exp.len, ZSW(repl_exp.s));
- if (repl_comp && (cap_cnt < repl_comp->max_pmatch) &&
- (repl_comp->max_pmatch != 0)) {
+ if (!(tflags&(DP_TFLAGS_PV_SUBST|DP_TFLAGS_PV_MATCH)) &&
+ repl_comp && (cap_cnt < repl_comp->max_pmatch) &&
+ (repl_comp->max_pmatch != 0))
+ {
LM_ERR("repl_exp %.*s refers to %d sub-expressions, but "
"subst_exp %.*s has only %d\n",
repl_exp.len, repl_exp.s, repl_comp->max_pmatch,
diff --git a/modules/dialplan/dp_repl.c b/modules/dialplan/dp_repl.c
index ee94be8..1e96ecf 100644
--- a/modules/dialplan/dp_repl.c
+++ b/modules/dialplan/dp_repl.c
@@ -188,7 +188,13 @@ int rule_translate(sip_msg_t *msg, str string, dpl_node_t * rule,
}
if(rule->tflags&DP_TFLAGS_PV_SUBST) {
- subst_comp = dpl_dynamic_pcre(msg, &rule->subst_exp, NULL);
+ subst_comp = dpl_dynamic_pcre(msg, &rule->subst_exp, &cap_cnt);
+ if (cap_cnt > MAX_REPLACE_WITH) {
+ LM_ERR("subst expression %.*s has too many sub-expressions\n",
+ rule->subst_exp.len, rule->subst_exp.s);
+ if(subst_comp) pcre_free(subst_comp);
+ return -1;
+ }
} else {
subst_comp = rule->subst_comp;
}