Bläddra i källkod

rls(k): few fixes

- string comparison that fails because sometimes one of the strings
  is '\0' terminated and the other never is.
- fix for when some non-RLS SUBSCRIBEs are not identified as such.
- fix for a small typo in an error diagnostic.
- patch by Peter Dunkley
Daniel-Constantin Mierla 14 år sedan
förälder
incheckning
2917d848a0
1 ändrade filer med 10 tillägg och 6 borttagningar
  1. 10 6
      modules_k/rls/subscribe.c

+ 10 - 6
modules_k/rls/subscribe.c

@@ -90,7 +90,7 @@ xmlNodePtr rls_get_by_service_uri(xmlDocPtr doc, str* uri)
 			val = XMLNodeGetAttrContentByName(node, "uri");
 			if(val!=NULL)
 			{
-				if((uri->len==strlen(val)) && (strcmp(val, uri->s)==0))
+				if((uri->len==strlen(val)) && (strncmp(val, uri->s, uri->len)==0))
 				{
 					xmlFree(val);
 					return node;
@@ -241,13 +241,17 @@ int rls_get_service_list(str *service_uri, str *user, str *domain,
 	*service_node = rls_get_by_service_uri(xmldoc, service_uri);
 	if(*service_node==NULL)
 	{
-		LM_ERR("service uri %.*s not found in rl document for user"
+		LM_DBG("service uri %.*s not found in rl document for user"
 			" sip:%.*s@%.*s\n", service_uri->len, service_uri->s,
 			user->len, user->s, domain->len, domain->s);
-		goto error;
+		rootdoc = NULL;
+		if(xmldoc!=NULL)
+			xmlFreeDoc(xmldoc);
+	}
+	else
+	{
+		*rootdoc = xmldoc;
 	}
-
-	*rootdoc = xmldoc;
 
 	rls_dbf.free_result(rls_db, result);
 	if(xcapdoc!=NULL)
@@ -621,7 +625,7 @@ int rls_handle_subscribe(struct sip_msg* msg, char* s1, char* s2)
 	if(send_full_notify(&subs, service_node, subs.version, &subs.pres_uri,
 				hash_code)<0)
 	{
-		LM_ERR("failed sending full state sotify\n");
+		LM_ERR("failed sending full state notify\n");
 		goto error;
 	}
 	/* send subscribe requests for all in the list */