[sr-dev] git:master:fb13cf36: pv: detect known headers provided with variable for $hfl(...) and $hflc(...)

Daniel-Constantin Mierla miconda at gmail.com
Mon Aug 22 12:42:02 CEST 2022


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-08-22T12:38:14+02:00

pv: detect known headers provided with variable for $hfl(...) and $hflc(...)

- GH #3194

---

Modified: src/modules/pv/pv_core.c

---

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

---

diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index afccbd4c7f6..5d310ecea7c 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -2223,6 +2223,7 @@ int pv_get_hfl(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
 	rr_t *rrb = NULL;
 	contact_t *cb = NULL;
 	hdr_field_t *hf = NULL;
+	hdr_field_t thdr = {0};
 	int n = 0;
 	str sval = STR_NULL;
 
@@ -2235,6 +2236,15 @@ int pv_get_hfl(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
 			LM_ERR("invalid name\n");
 			return -1;
 		}
+		parse_hname2_short(tv.rs.s, tv.rs.s + tv.rs.len, &thdr);
+		if(thdr.type==HDR_ERROR_T) {
+			LM_ERR("error parsing header name [%.*s]\n", tv.rs.len, tv.rs.s);
+			return pv_get_sintval(msg, param, res, 0);
+		}
+		if(thdr.type!=HDR_OTHER_T) {
+			tv.flags = 0;
+			tv.ri = thdr.type;
+		}
 	} else {
 		if(param->pvn.u.isname.type == AVP_NAME_STR) {
 			tv.flags = PV_VAL_STR;
@@ -2458,6 +2468,7 @@ int pv_get_hflc(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
 	rr_t *rrb = NULL;
 	contact_t *cb = NULL;
 	hdr_field_t *hf = NULL;
+	hdr_field_t thdr = {0};
 	int n = 0;
 
 	if(msg==NULL || res==NULL || param==NULL)
@@ -2469,6 +2480,15 @@ int pv_get_hflc(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
 			LM_ERR("invalid name\n");
 			return pv_get_sintval(msg, param, res, 0);
 		}
+		parse_hname2_short(tv.rs.s, tv.rs.s + tv.rs.len, &thdr);
+		if(thdr.type==HDR_ERROR_T) {
+			LM_ERR("error parsing header name [%.*s]\n", tv.rs.len, tv.rs.s);
+			return pv_get_sintval(msg, param, res, 0);
+		}
+		if(thdr.type!=HDR_OTHER_T) {
+			tv.flags = 0;
+			tv.ri = thdr.type;
+		}
 	} else {
 		if(param->pvn.u.isname.type == AVP_NAME_STR) {
 			tv.flags = PV_VAL_STR;




More information about the sr-dev mailing list