From 1d8f45e88a8bc79646a330f5531c6b767e547754 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Thu, 17 Sep 2020 14:21:30 +0200 Subject: [PATCH] tmx: safety check of expected route blocks for using $T_*() variables - related to GH #2479 (cherry picked from commit 2e7710e292a649c6c57e46d5994d3b2cf3815865) --- src/modules/tmx/t_var.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/modules/tmx/t_var.c b/src/modules/tmx/t_var.c index 15938fcd9ea..1aa1dc0cff1 100644 --- a/src/modules/tmx/t_var.c +++ b/src/modules/tmx/t_var.c @@ -305,6 +305,11 @@ int pv_get_t_var_req(struct sip_msg *msg, pv_param_t *param, { pv_spec_t *pv=NULL; + if(!is_route_type(CORE_ONREPLY_ROUTE|TM_ONREPLY_ROUTE)) { + LM_DBG("used in unsupported route block - type %d\n", get_route_type()); + return pv_get_null(msg, param, res); + } + if(pv_t_update_req(msg)) return pv_get_null(msg, param, res); @@ -320,6 +325,11 @@ int pv_get_t_var_rpl(struct sip_msg *msg, pv_param_t *param, { pv_spec_t *pv=NULL; + if(!is_route_type(FAILURE_ROUTE|BRANCH_FAILURE_ROUTE)) { + LM_DBG("used in unsupported route block - type %d\n", get_route_type()); + return pv_get_null(msg, param, res); + } + if(pv_t_update_rpl(msg)) return pv_get_null(msg, param, res); @@ -335,6 +345,11 @@ int pv_get_t_var_branch(struct sip_msg *msg, pv_param_t *param, { pv_spec_t *pv=NULL; + if(!is_route_type(FAILURE_ROUTE|BRANCH_FAILURE_ROUTE|TM_ONREPLY_ROUTE)) { + LM_DBG("used in unsupported route block - type %d\n", get_route_type()); + return pv_get_null(msg, param, res); + } + if(pv_t_update_rpl(msg)) return pv_get_null(msg, param, res); @@ -350,6 +365,11 @@ int pv_get_t_var_inv(struct sip_msg *msg, pv_param_t *param, { pv_spec_t *pv=NULL; + if(!is_route_type(REQUEST_ROUTE)) { + LM_DBG("used in unsupported route block - type %d\n", get_route_type()); + return pv_get_null(msg, param, res); + } + if(pv_t_update_inv(msg)) return pv_get_null(msg, param, res);