Module: kamailio
Branch: master
Commit: 80b3c37557d446bfe9ca5a5f469a42af60648280
URL:
https://github.com/kamailio/kamailio/commit/80b3c37557d446bfe9ca5a5f469a42a…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-12-08T08:12:49+01:00
pv: {param.count} accept static string "," as delimiter
---
Modified: src/modules/pv/pv_trans.c
---
Diff:
https://github.com/kamailio/kamailio/commit/80b3c37557d446bfe9ca5a5f469a42a…
Patch:
https://github.com/kamailio/kamailio/commit/80b3c37557d446bfe9ca5a5f469a42a…
---
diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index a515393869..f8074170ac 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -2127,28 +2127,28 @@ int tr_eval_line(struct sip_msg *msg, tr_param_t *tp, int
subtype,
} \
}
-#define _tr_parse_sparam(_p, _p0, _tp, _spec, _ps, _in, _s) \
+/**
+ * _m: 1 - the parameter value can be the TR_PARAM_MARKER; 0 - not allowed
+ */
+#define _tr_parse_sparamx(_p, _p0, _tp, _spec, _ps, _in, _s, _m) \
while(is_in_str(_p, _in) && (*_p==' ' || *_p=='\t' ||
*_p=='\n')) _p++; \
if(*_p==PV_MARKER) \
{ /* pseudo-variable */ \
_spec = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t)); \
- if(_spec==NULL) \
- { \
+ if(_spec==NULL) { \
LM_ERR("no more private memory!\n"); \
goto error; \
} \
_s.s = _p; _s.len = _in->s + _in->len - _p; \
_p0 = pv_parse_spec(&_s, _spec); \
- if(_p0==NULL) \
- { \
+ if(_p0==NULL) { \
LM_ERR("invalid spec in substr transformation: %.*s!\n", \
_in->len, _in->s); \
goto error; \
} \
_p = _p0; \
_tp = (tr_param_t*)pkg_malloc(sizeof(tr_param_t)); \
- if(_tp==NULL) \
- { \
+ if(_tp==NULL) { \
LM_ERR("no more private memory!\n"); \
goto error; \
} \
@@ -2159,17 +2159,23 @@ int tr_eval_line(struct sip_msg *msg, tr_param_t *tp, int
subtype,
_ps = _p; \
while(is_in_str(_p, _in) && *_p!='\t' && *_p!='\n' \
&& *_p!=TR_PARAM_MARKER && *_p!=TR_RBRACKET) \
- _p++; \
- if(*_p=='\0') \
- { \
+ _p++; \
+ if(*_p=='\0') { \
LM_ERR("invalid param in transformation: %.*s!!\n", \
_in->len, _in->s); \
goto error; \
} \
+ if(_m && *_p==TR_PARAM_MARKER) { \
+ _p++; \
+ if(*_p=='\0') { \
+ LM_ERR("invalid param in transformation: %.*s!!!\n", \
+ _in->len, _in->s); \
+ goto error; \
+ } \
+ } \
_tp = (tr_param_t*)pkg_malloc(sizeof(tr_param_t)); \
- if(_tp==NULL) \
- { \
- LM_ERR("no more private memory!\n"); \
+ if(_tp==NULL) { \
+ LM_ERR("no more private memory!!\n"); \
goto error; \
} \
memset(_tp, 0, sizeof(tr_param_t)); \
@@ -2178,6 +2184,8 @@ int tr_eval_line(struct sip_msg *msg, tr_param_t *tp, int subtype,
_tp->v.s.len = _p - _ps; \
}
+#define _tr_parse_sparam(_p, _p0, _tp, _spec, _ps, _in, _s) \
+ _tr_parse_sparamx(_p, _p0, _tp, _spec, _ps, _in, _s, 0)
/*!
* \brief Helper fuction to parse a string transformation
@@ -2843,13 +2851,11 @@ char* tr_parse_paramlist(str* in, trans_t *t)
goto done;
} else if(name.len==5 && strncasecmp(name.s, "count", 5)==0) {
t->subtype = TR_PL_COUNT;
- if(*p==TR_PARAM_MARKER)
- {
+ if(*p==TR_PARAM_MARKER) {
start_pos = ++p;
- _tr_parse_sparam(p, p0, tp, spec, ps, in, s);
+ _tr_parse_sparamx(p, p0, tp, spec, ps, in, s, 1);
t->params = tp;
- if (tp->type != TR_PARAM_SPEC && p - start_pos != 1)
- {
+ if (tp->type != TR_PARAM_SPEC && p - start_pos != 1) {
LM_ERR("invalid separator in transformation: "
"%.*s\n", in->len, in->s);
goto error;
@@ -2857,8 +2863,7 @@ char* tr_parse_paramlist(str* in, trans_t *t)
tp = 0;
while(*p && (*p==' ' || *p=='\t' || *p=='\n')) p++;
- if(*p!=TR_RBRACKET)
- {
+ if(*p!=TR_RBRACKET) {
LM_ERR("invalid name transformation: %.*s!\n",
in->len, in->s);
goto error;