[sr-dev] git:master: modules_k: ratelimit - rl_check(): strict pipe boundary checking

Ovidiu Sas osas at voipembedded.com
Sat Jul 3 01:08:31 CEST 2010


Module: sip-router
Branch: master
Commit: 721354929365b57a1e0337dccde9d58ce8d03945
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=721354929365b57a1e0337dccde9d58ce8d03945

Author: Ovidiu Sas <osas at voipembedded.com>
Committer: Ovidiu Sas <osas at voipembedded.com>
Date:   Fri Jul  2 19:11:40 2010 -0400

modules_k: ratelimit - rl_check(): strict pipe boundary checking

---

 modules_k/ratelimit/ratelimit.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/modules_k/ratelimit/ratelimit.c b/modules_k/ratelimit/ratelimit.c
index b949c68..628a486 100644
--- a/modules_k/ratelimit/ratelimit.c
+++ b/modules_k/ratelimit/ratelimit.c
@@ -758,11 +758,16 @@ static int rl_check(struct sip_msg * msg, int forced_pipe)
 	int que_id, pipe_id, ret;
 	str method = msg->first_line.u.request.method;
 
+	if (forced_pipe >=0 && (forced_pipe>=MAX_PIPES || *pipes[forced_pipe].algo==PIPE_ALGO_NOP)) {
+		LM_ERR("forced pipe %d out of range or not defined", forced_pipe);
+		return -1;
+	}
+
 	LOCK_GET(rl_lock);
 	if (forced_pipe < 0) { 
 		if (find_queue(msg, &que_id)) {
 			pipe_id = que_id = 0;
-			ret = 1;
+			ret = -1;
 			goto out_release;
 		}
 		pipe_id = *queues[que_id].pipe;
@@ -817,13 +822,8 @@ static int w_rl_check_forced_pipe(struct sip_msg* msg, char *p1, char *p2)
 {
 	int pipe;
 
-	if (p1) {
-		pipe = (int)(unsigned int)(unsigned long)p1;
-		LM_DBG("trying pipe %d\n", pipe);
-	} else {
-		pipe = -1;
-	}
-
+	pipe = (int)(unsigned int)(unsigned long)p1;
+	LM_DBG("trying pipe %d\n", pipe);
 	return rl_check(msg, pipe);
 }
 




More information about the sr-dev mailing list