[sr-dev] git:master:96455755: pv: proper evaluation of pv param for param.count transformation

Daniel-Constantin Mierla miconda at gmail.com
Tue Mar 28 16:01:44 CEST 2017


Module: kamailio
Branch: master
Commit: 964557553fd39fca1de35cf7d2f9e64134da7495
URL: https://github.com/kamailio/kamailio/commit/964557553fd39fca1de35cf7d2f9e64134da7495

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-03-28T15:59:50+02:00

pv: proper evaluation of pv param for param.count transformation

- reported by GH #1041

---

Modified: src/modules/pv/pv_trans.c

---

Diff:  https://github.com/kamailio/kamailio/commit/964557553fd39fca1de35cf7d2f9e64134da7495.diff
Patch: https://github.com/kamailio/kamailio/commit/964557553fd39fca1de35cf7d2f9e64134da7495.patch

---

diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index f15975e..6ad9a97 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -1294,6 +1294,7 @@ int tr_eval_paramlist(struct sip_msg *msg, tr_param_t *tp, int subtype,
 		pv_value_t *val)
 {
 	pv_value_t v;
+	pv_value_t vs;
 	str sv;
 	int n, i;
 	char separator = ';';
@@ -1307,17 +1308,23 @@ int tr_eval_paramlist(struct sip_msg *msg, tr_param_t *tp, int subtype,
 	{
 		if (subtype == TR_PL_COUNT)
 		{
-			if(tp->type != TR_PARAM_STRING || tp->v.s.len != 1)
-				return -1;
-
-			separator = tp->v.s.s[0];
-		}
-		else if (tp->next != NULL)
-		{
+			if(tp->type != TR_PARAM_STRING) {
+				if(pv_get_spec_value(msg, (pv_spec_t*)tp->v.data, &vs)!=0
+						|| (!(vs.flags&PV_VAL_STR)) || vs.rs.len<=0)
+				{
+					LM_ERR("value cannot get p1\n");
+					return -1;
+				}
+				separator = vs.rs.s[0];
+			} else {
+				if(tp->v.s.len != 1)
+					return -1;
+				separator = tp->v.s.s[0];
+			}
+		} else if (tp->next != NULL) {
 			if(tp->next->type != TR_PARAM_STRING
 					|| tp->next->v.s.len != 1)
 				return -1;
-
 			separator = tp->next->v.s.s[0];
 		}
 	}




More information about the sr-dev mailing list