Browse code

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 authored on 30/06/2009 15:44:54
Showing 1 changed files
... ...
@@ -801,16 +801,16 @@ int select_uri_user(str* res, select_t* s, struct sip_msg* msg)
801 801
  *
802 802
  * val is set to the value of the parameter.
803 803
  */
804
-static inline int search_param(str *params, char *name, int name_len,
804
+static inline int search_param(str params, char *name, int name_len,
805 805
 				str *val)
806 806
 {
807 807
 	param_hooks_t h;
808 808
 	param_t *p, *list;
809 809
 
810
-	if (params->s == NULL)
810
+	if (params.s == NULL)
811 811
 		return 0;
812 812
 
813
-	if (parse_params(params, CLASS_ANY, &h, &list) < 0)
813
+	if (parse_params(&params, CLASS_ANY, &h, &list) < 0)
814 814
 		return -1;
815 815
 	for (p = list; p; p=p->next) {
816 816
 		if ((p->name.len == name_len)
... ...
@@ -840,12 +840,12 @@ int select_uri_rn_user(str* res, select_t* s, struct sip_msg* msg)
840 840
 	}
841 841
 
842 842
 	/* search for the "rn" parameter */
843
-	if ((ret = search_param(&select_uri_p->params, "rn", 2, &val)) != 0)
843
+	if ((ret = search_param(select_uri_p->params, "rn", 2, &val)) != 0)
844 844
 		goto done;
845 845
 
846 846
 	if (select_uri_p->sip_params.s != select_uri_p->params.s) {
847 847
 		/* check also the original sip: URI parameters */
848
-		if ((ret = search_param(&select_uri_p->sip_params, "rn", 2, &val)) != 0)
848
+		if ((ret = search_param(select_uri_p->sip_params, "rn", 2, &val)) != 0)
849 849
 			goto done;
850 850
 	}
851 851
 
... ...
@@ -1015,7 +1015,7 @@ int select_any_params(str* res, select_t* s, struct sip_msg* msg)
1015 1015
 	
1016 1016
 	if (!res->len) return -1;
1017 1017
 
1018
-	if (search_param(res, wanted->s, wanted->len, res) <= 0) {
1018
+	if (search_param(*res, wanted->s, wanted->len, res) <= 0) {
1019 1019
 		DBG("SELECT ...uri.params.%s NOT FOUND !\n", wanted->s);
1020 1020
 		return -1;
1021 1021
 	} else {