Browse code

core: clone modparamx evaluated values

Daniel-Constantin Mierla authored on 29/06/2021 07:18:05
Showing 1 changed files
... ...
@@ -31,11 +31,14 @@
31 31
 #include "dprint.h"
32 32
 #include "fmsg.h"
33 33
 #include "pvar.h"
34
+#include "str_list.h"
34 35
 #include "mem/mem.h"
35 36
 #include <sys/types.h>
36 37
 #include <regex.h>
37 38
 #include <string.h>
38 39
 
40
+static str_list_t *_ksr_modparam_strlist = NULL;
41
+
39 42
 static char *get_mod_param_type_str(int ptype)
40 43
 {
41 44
 	if(ptype & PARAM_USE_FUNC) {
... ...
@@ -190,6 +193,7 @@ int modparamx_set(char* mname, char* pname, modparam_t ptype, void* pval)
190 193
 	char* epname;
191 194
 	pv_spec_t *pvs;
192 195
 	pv_value_t pvv;
196
+	str_list_t *sb;
193 197
 
194 198
 	emname = mname;
195 199
 	if(strchr(mname, '$') != NULL) {
... ...
@@ -197,7 +201,12 @@ int modparamx_set(char* mname, char* pname, modparam_t ptype, void* pval)
197 201
 		sfmt.s = mname;
198 202
 		sfmt.len = strlen(sfmt.s);
199 203
 		if(pv_eval_str(fmsg, &seval, &sfmt)>=0) {
200
-			emname = seval.s;
204
+			sb = str_list_block_add(&_ksr_modparam_strlist, seval.s, seval.len);
205
+			if(sb==NULL) {
206
+				LM_ERR("failed to handle parameter type: %d\n", ptype);
207
+				return -1;
208
+			}
209
+			emname = sb->s.s;
201 210
 		}
202 211
 	}
203 212
 
... ...
@@ -207,7 +216,12 @@ int modparamx_set(char* mname, char* pname, modparam_t ptype, void* pval)
207 216
 		sfmt.s = pname;
208 217
 		sfmt.len = strlen(sfmt.s);
209 218
 		if(pv_eval_str(fmsg, &seval, &sfmt)>=0) {
210
-			epname = seval.s;
219
+			sb = str_list_block_add(&_ksr_modparam_strlist, seval.s, seval.len);
220
+			if(sb==NULL) {
221
+				LM_ERR("failed to handle parameter type: %d\n", ptype);
222
+				return -1;
223
+			}
224
+			epname = sb->s.s;
211 225
 		}
212 226
 	}
213 227
 
... ...
@@ -218,8 +232,13 @@ int modparamx_set(char* mname, char* pname, modparam_t ptype, void* pval)
218 232
 				sfmt.s = (char*)pval;
219 233
 				sfmt.len = strlen(sfmt.s);
220 234
 				if(pv_eval_str(fmsg, &seval, &sfmt)>=0) {
235
+					sb = str_list_block_add(&_ksr_modparam_strlist, seval.s, seval.len);
236
+					if(sb==NULL) {
237
+						LM_ERR("failed to handle parameter type: %d\n", ptype);
238
+						return -1;
239
+					}
221 240
 					return set_mod_param_regex(emname, epname, PARAM_STRING,
222
-							(void*)seval.s);
241
+							(void*)sb->s.s);
223 242
 				} else {
224 243
 					LM_ERR("failed to evaluate parameter [%s]\n", (char*)pval);
225 244
 					return -1;
... ...
@@ -267,8 +286,14 @@ int modparamx_set(char* mname, char* pname, modparam_t ptype, void* pval)
267 286
 						sfmt.len, sfmt.s);
268 287
 				return -1;
269 288
 			}
289
+			sb = str_list_block_add(&_ksr_modparam_strlist, pvv.rs.s, pvv.rs.len);
290
+			if(sb==NULL) {
291
+				LM_ERR("failed to handle parameter type: %d\n", ptype);
292
+				return -1;
293
+			}
294
+
270 295
 			return set_mod_param_regex(emname, epname, PARAM_STRING,
271
-							(void*)pvv.rs.s);
296
+							(void*)sb->s.s);
272 297
 		default:
273 298
 			LM_ERR("invalid parameter type: %d\n", ptype);
274 299
 			return -1;