From 59389b288fd50369226681b309c0895de03d7b77 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Tue, 23 Jun 2015 16:45:17 +0200 Subject: [PATCH] rtjson: safety check for branch index stored interanlly in xavp --- modules/rtjson/rtjson_routing.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/rtjson/rtjson_routing.c b/modules/rtjson/rtjson_routing.c index c9ee5c3a6fd..bb59da51f6c 100644 --- a/modules/rtjson/rtjson_routing.c +++ b/modules/rtjson/rtjson_routing.c @@ -677,6 +677,10 @@ int rtjson_update_branch(sip_msg_t *msg) LM_WARN("no idx for routing\n"); return -1; } + if(iavp->val.v.i<=0) { + LM_WARN("invalid branch idx for routing\n"); + return -1; + } srjson_InitDoc(&tdoc, NULL); @@ -708,7 +712,8 @@ int rtjson_update_branch(sip_msg_t *msg) nj = tj->child; i = 0; - while(nj && ival.v.i) { + /* stop at number of branches - 1 */ + while(nj && ival.v.i-1) { nj = nj->next; i++; }