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
mr9.1
Victor Seva 6 years ago
parent bf28749611
commit 7b61a35e6f

@ -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 = &param->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)

Loading…
Cancel
Save