[sr-dev] git:oej/permissionsrpc: Fix the test-uri function.

Olle E. Johansson oej at edvina.net
Tue Jan 8 10:23:20 CET 2013


Module: sip-router
Branch: oej/permissionsrpc
Commit: 4c8dd7b4e8bd35b028187ee223b6d818260921b8
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4c8dd7b4e8bd35b028187ee223b6d818260921b8

Author: Olle E. Johansson <oej at edvina.net>
Committer: Olle E. Johansson <oej at edvina.net>
Date:   Tue Jan  8 09:33:47 2013 +0100

Fix the test-uri function.

Thanks to Daniel for helping me.

---

 modules_k/permissions/mi.c |   24 ++++++++++--------------
 1 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/modules_k/permissions/mi.c b/modules_k/permissions/mi.c
index ee17534..e38bc05 100644
--- a/modules_k/permissions/mi.c
+++ b/modules_k/permissions/mi.c
@@ -255,46 +255,42 @@ struct mi_root* mi_allow_uri(struct mi_root *cmd, void *param)
  */
 void rpc_test_uri(rpc_t* rpc, void* c)
 {
-    	str *basenamep, *urip, *contactp;
+    	str basenamep, urip, contactp;
 	char basename[MAX_FILE_LEN + 1];
 	char uri[MAX_URI_SIZE + 1], contact[MAX_URI_SIZE + 1]; 
 	unsigned int allow_suffix_len;
-	int i;
 
 	if (rpc->scan(c, "S", &basenamep) != 1) {
 		rpc->fault(c, 500, "Not enough parameters (basename, URI and contact)");
 		return;
 	}
-	LM_DBG("Basename %s length %d strlen(%d)\n", basenamep, basenamep->len, strlen(basenamep));
 	if (rpc->scan(c, "S", &urip) != 1) {
 		rpc->fault(c, 500, "Not enough parameters (basename, URI and contact)");
 		return;
 	}
-	LM_DBG("URI %s length %d \n", urip, urip->len);
 	if (rpc->scan(c, "S", &contactp) != 1) {
 		rpc->fault(c, 500, "Not enough parameters (basename, URI and contact)");
 		return;
 	}
-	LM_DBG("Contact %s length %d size %d\n", contactp, contactp->len, sizeof(contactp->s) - 1);
 
 	/* For some reason, rtp->scan doesn't set the length properly */
-    	if (contactp->len > MAX_URI_SIZE) {
+    	if (contactp.len > MAX_URI_SIZE) {
 		rpc->fault(c, 500, "Contact is too long");
 		return;
 	}
 	allow_suffix_len = strlen(allow_suffix);
-	if (basenamep->len + allow_suffix_len + 1 > MAX_FILE_LEN) {
+	if (basenamep.len + allow_suffix_len + 1 > MAX_FILE_LEN) {
 		rpc->fault(c, 500, "Basename is too long");
 		return;
 	}
 
-	memcpy(basename, basenamep->s, basenamep->len);
-	memcpy(basename + basenamep->len, allow_suffix, allow_suffix_len);
-	basename[basenamep->len + allow_suffix_len] = 0;
-    	memcpy(uri, urip->s, urip->len);
-	memcpy(contact, contactp->s, contactp->len);
-	contact[contactp->len] = 0;
-    	uri[urip->len] = 0;
+	memcpy(basename, basenamep.s, basenamep.len);
+	memcpy(basename + basenamep.len, allow_suffix, allow_suffix_len);
+	basename[basenamep.len + allow_suffix_len] = 0;
+    	memcpy(uri, urip.s, urip.len);
+	memcpy(contact, contactp.s, contactp.len);
+	contact[contactp.len] = 0;
+    	uri[urip.len] = 0;
 
 	if (allow_test(basename, uri, contact) == 1) {
 		rpc->printf(c, "Allowed");




More information about the sr-dev mailing list