From 7b61a35e6fe8428697150ca7a4ce3ea568b0c2bc Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Tue, 8 Sep 2020 10:23:21 +0200 Subject: [PATCH] TT#91452 pv_headers: get_header(), remove annoying errors * if we use pv_get_spec_name() cfgt will throw errors trying to get values like $x_hdr($xavp(whatever=>y)) when there's no $xavp(whatever=>y) Change-Id: I88f91e30f969e309c566f6c15495796350b0ba5f --- .../pv_headers-fix-x_hdr-index-on-get.patch | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/debian/patches/upstream/pv_headers-fix-x_hdr-index-on-get.patch b/debian/patches/upstream/pv_headers-fix-x_hdr-index-on-get.patch index 57766a8e3..dec4db34c 100644 --- a/debian/patches/upstream/pv_headers-fix-x_hdr-index-on-get.patch +++ b/debian/patches/upstream/pv_headers-fix-x_hdr-index-on-get.patch @@ -4,14 +4,14 @@ Subject: pv_headers: fix $x_hdr index on get * previously we where not supporting pseudo-variables as index --- - src/modules/pv_headers/pvh_xavp.c | 35 +++++++++++++++-------------------- - 1 file changed, 15 insertions(+), 20 deletions(-) + src/modules/pv_headers/pvh_xavp.c | 28 +++++++++++++++++----------- + 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/modules/pv_headers/pvh_xavp.c b/src/modules/pv_headers/pvh_xavp.c -index ad5ba9d..7cba757 100644 +index ad5ba9d..3e0fcc0 100644 --- a/src/modules/pv_headers/pvh_xavp.c +++ b/src/modules/pv_headers/pvh_xavp.c -@@ -539,38 +539,33 @@ int pvh_get_header(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) +@@ -539,12 +539,12 @@ int pvh_get_header(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) sr_xavp_t *xavi = NULL; sr_xval_t *xval = NULL; pv_value_t tv; @@ -22,31 +22,32 @@ index ad5ba9d..7cba757 100644 int cnt = 0; - idx = param->pvi.u.ival; -+ if(pv_get_spec_name(msg, param, &tv) != 0 || (!(tv.flags & PV_VAL_STR))) { -+ LM_ERR("invalid header name, must be a string\n"); -+ return -1; -+ } -+ hname = &tv.rs; - -- if(param->pvn.type == PV_NAME_PVAR) { -- if(pv_get_spec_value(msg, (pv_spec_p)(param->pvn.u.dname), &tv) != 0) { -- LM_ERR("cannot get avp value\n"); -- return -1; -- } -- if(!(tv.flags & PV_VAL_STR)) { -- return pv_get_null(msg, param, res); -- } +- ++ /* if we use pv_get_spec_name() cfgt will throw errors trying to get values ++ like $x_hdr($xavp(whatever=>y)) when there's no $xavp(whatever=>y) */ + if(param->pvn.type == PV_NAME_PVAR) { + if(pv_get_spec_value(msg, (pv_spec_p)(param->pvn.u.dname), &tv) != 0) { + LM_ERR("cannot get avp value\n"); +@@ -553,24 +553,30 @@ int pvh_get_header(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) + if(!(tv.flags & PV_VAL_STR)) { + return pv_get_null(msg, param, res); + } - hname = tv.rs; - } else if(param->pvn.u.isname.type == AVP_NAME_STR) { - hname = param->pvn.u.isname.name.s; -- } else { -- return pv_get_null(msg, param, res); ++ hname = &tv.rs; ++ } else if(param->pvn.u.isname.type & AVP_NAME_STR) { ++ hname = ¶m->pvn.u.isname.name.s; + } else { + return pv_get_null(msg, param, res); + } + + /* get the index */ + if(pv_get_spec_index(msg, param, &idx, &idxf) != 0) { + LM_ERR("invalid index\n"); + return -1; - } - ++ } ++ if(idx < 0) { - if((xavi = pvh_xavi_get_child(msg, &xavi_name, &hname)) == NULL) + if((xavi = pvh_xavi_get_child(msg, &xavi_name, hname)) == NULL)