[sr-dev] git:kamailio_3.0: dialplan: fix matching string comparison op

Daniel-Constantin Mierla miconda at gmail.com
Sun Jan 2 16:19:00 CET 2011


Module: sip-router
Branch: kamailio_3.0
Commit: 5392eb7f167d42734de1641d8f7e9f95e6fabc72
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5392eb7f167d42734de1641d8f7e9f95e6fabc72

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Sun Jan  2 16:10:40 2011 +0100

dialplan: fix matching string comparison op

- the return code was tested as for match of regexp, which led to
  mismatches for str comparison
- credits to Jordan Levy
(cherry picked from commit 88f03cb2cf50ee0b09fda8b3c4c4651553ddd176)

---

 modules/dialplan/dp_repl.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/modules/dialplan/dp_repl.c b/modules/dialplan/dp_repl.c
index 21dbd26..e9b875d 100644
--- a/modules/dialplan/dp_repl.c
+++ b/modules/dialplan/dp_repl.c
@@ -304,21 +304,23 @@ search_rule:
 
 			case EQUAL_OP:
 				LM_DBG("equal operator testing\n");
-			    if(rulep->match_exp.len != input.len)
+			    if(rulep->match_exp.len != input.len) {
 					rez = -1;
-			    else 
+				} else {
 					rez = strncmp(rulep->match_exp.s,input.s,input.len);
-		    break;
+					rez = (rez==0)?0:-1;
+				}
+			break;
 	    
 			default:
-			    LM_ERR("bogus match operator code %i\n", rulep->matchop);
+				LM_ERR("bogus match operator code %i\n", rulep->matchop);
 				return -1;
 		}
 		if(rez >= 0)
-		    goto repl;
+			goto repl;
 	}
-    /*test the rules with len 0*/
-    if(indexp->len){
+	/*test the rules with len 0*/
+	if(indexp->len){
 		for(indexp = indexp->next; indexp!=NULL; indexp = indexp->next)
 			if(!indexp->len)
 				break;




More information about the sr-dev mailing list