Browse Source

select_core: fix @ruri.rn_user moving parsed ptr

- changed str* to str parameter type in search_param function to keep value
  of the parameter intact upon function return, otherwise the function moved
  the ptr to the beginning of the rn parameter or at the end of the pameters string.
Michal Matyska 16 years ago
parent
commit
21ba29a12f
1 changed files with 6 additions and 6 deletions
  1. 6 6
      select_core.c

+ 6 - 6
select_core.c

@@ -801,16 +801,16 @@ int select_uri_user(str* res, select_t* s, struct sip_msg* msg)
  *
  * val is set to the value of the parameter.
  */
-static inline int search_param(str *params, char *name, int name_len,
+static inline int search_param(str params, char *name, int name_len,
 				str *val)
 {
 	param_hooks_t h;
 	param_t *p, *list;
 
-	if (params->s == NULL)
+	if (params.s == NULL)
 		return 0;
 
-	if (parse_params(params, CLASS_ANY, &h, &list) < 0)
+	if (parse_params(&params, CLASS_ANY, &h, &list) < 0)
 		return -1;
 	for (p = list; p; p=p->next) {
 		if ((p->name.len == name_len)
@@ -840,12 +840,12 @@ int select_uri_rn_user(str* res, select_t* s, struct sip_msg* msg)
 	}
 
 	/* search for the "rn" parameter */
-	if ((ret = search_param(&select_uri_p->params, "rn", 2, &val)) != 0)
+	if ((ret = search_param(select_uri_p->params, "rn", 2, &val)) != 0)
 		goto done;
 
 	if (select_uri_p->sip_params.s != select_uri_p->params.s) {
 		/* check also the original sip: URI parameters */
-		if ((ret = search_param(&select_uri_p->sip_params, "rn", 2, &val)) != 0)
+		if ((ret = search_param(select_uri_p->sip_params, "rn", 2, &val)) != 0)
 			goto done;
 	}
 
@@ -1015,7 +1015,7 @@ int select_any_params(str* res, select_t* s, struct sip_msg* msg)
 	
 	if (!res->len) return -1;
 
-	if (search_param(res, wanted->s, wanted->len, res) <= 0) {
+	if (search_param(*res, wanted->s, wanted->len, res) <= 0) {
 		DBG("SELECT ...uri.params.%s NOT FOUND !\n", wanted->s);
 		return -1;
 	} else {