Module: kamailio
Branch: master
Commit: 8038fba2dd056193b37a5c2571f2d4d910c47e73
URL:
https://github.com/kamailio/kamailio/commit/8038fba2dd056193b37a5c2571f2d4d…
Author: Xenofon Karamanos <xk(a)gilawa.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-01-05T10:25:02+01:00
pv_core: Fix negative index bug for hfl()
Before: -1 yielded null and -2 the last element of a header
---
Modified: src/modules/pv/pv_core.c
---
Diff:
https://github.com/kamailio/kamailio/commit/8038fba2dd056193b37a5c2571f2d4d…
Patch:
https://github.com/kamailio/kamailio/commit/8038fba2dd056193b37a5c2571f2d4d…
---
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index d98abbf975d..129247f2688 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -2149,7 +2149,7 @@ int pv_get_hfl(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
return pv_get_null(msg, param, res);
}
if(idx < 0) {
- n = 1;
+ n = 0;
/* count Via header bodies */
for(hf = msg->h_via1; hf != NULL; hf = hf->next) {
if(hf->type == HDR_VIA_T) {
@@ -2207,7 +2207,7 @@ int pv_get_hfl(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
}
if(idx < 0) {
- n = 1;
+ n = 0;
/* count Record-Route/Route header bodies */
for(; hf != NULL; hf = hf->next) {
if(hf->type == tv.ri) {
@@ -2290,7 +2290,7 @@ int pv_get_hfl(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
return pv_get_null(msg, param, res);
}
if(idx < 0) {
- n = 1;
+ n = 0;
/* count Contact header bodies */
for(hf = msg->contact; hf != NULL; hf = hf->next) {
if(hf->type == HDR_CONTACT_T) {