[sr-dev] git:4.3:e5452003: pv: convert negative index to positive position for $branch(...)

Daniel-Constantin Mierla miconda at gmail.com
Tue Jun 9 10:40:11 CEST 2015


Module: kamailio
Branch: 4.3
Commit: e5452003a5219e50d26baa72e773fa1690b45a3d
URL: https://github.com/kamailio/kamailio/commit/e5452003a5219e50d26baa72e773fa1690b45a3d

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-06-09T10:33:48+02:00

pv: convert negative index to positive position for $branch(...)

- better access to branch structures

(cherry picked from commit 6461b799ce64315b72b8e2f4f7e4617603330833)

---

Modified: modules/pv/pv_branch.c

---

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

---

diff --git a/modules/pv/pv_branch.c b/modules/pv/pv_branch.c
index e35330a..34626b3 100644
--- a/modules/pv/pv_branch.c
+++ b/modules/pv/pv_branch.c
@@ -133,6 +133,16 @@ int pv_set_branchx_helper(sip_msg_t *msg, pv_param_t *param,
 			LM_ERR("invalid index\n");
 			return -1;
 		}
+		if(idx<0)
+		{
+			if((int)nr_branches + idx >= 0) {
+				idx += nr_branches;
+			} else {
+				LM_ERR("index too low: %d (%u)\n", idx, nr_branches);
+				return -1;
+			}
+		}
+		LM_DBG("managing branch index %d (%u)\n", idx, nr_branches);
 		br = get_sip_branch(idx);
 	}
 




More information about the sr-dev mailing list