[sr-dev] git:5.5:6bf1c6af: core: ppcfg - clone value for substdef

Daniel-Constantin Mierla miconda at gmail.com
Mon Jul 12 15:40:22 CEST 2021


Module: kamailio
Branch: 5.5
Commit: 6bf1c6af774f6b26597e639e90ce7cb584b626a3
URL: https://github.com/kamailio/kamailio/commit/6bf1c6af774f6b26597e639e90ce7cb584b626a3

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-07-12T15:34:30+02:00

core: ppcfg - clone value for substdef

- GH #2788

(cherry picked from commit 56d41f6238f39d0046c97527abcb23b8dd7924be)

---

Modified: src/core/ppcfg.c

---

Diff:  https://github.com/kamailio/kamailio/commit/6bf1c6af774f6b26597e639e90ce7cb584b626a3.diff
Patch: https://github.com/kamailio/kamailio/commit/6bf1c6af774f6b26597e639e90ce7cb584b626a3.patch

---

diff --git a/src/core/ppcfg.c b/src/core/ppcfg.c
index a5aa1d3e28..73c0a2ef3c 100644
--- a/src/core/ppcfg.c
+++ b/src/core/ppcfg.c
@@ -30,6 +30,7 @@
 #include "ut.h"
 #include "re.h"
 #include "pvar.h"
+#include "str_list.h"
 #include "dprint.h"
 
 #include "ppcfg.h"
@@ -44,6 +45,7 @@ typedef struct _pp_subst_rule {
 static pp_subst_rule_t *pp_subst_rules_head = NULL;
 static pp_subst_rule_t *pp_subst_rules_tail = NULL;
 static int _pp_ifdef_level = 0;
+static str_list_t *_ksr_substdef_strlist = NULL;
 
 int pp_subst_add(char *data)
 {
@@ -94,6 +96,7 @@ int pp_substdef_add(char *data, int mode)
 	str defvalue;
 	str newval;
 	sip_msg_t *fmsg;
+	str_list_t *sb;
 
 	if(pp_subst_add(data)<0) {
 		LM_ERR("subst rule cannot be added\n");
@@ -146,7 +149,12 @@ int pp_substdef_add(char *data, int mode)
 	if(memchr(defvalue.s, '$', defvalue.len) != NULL) {
 		fmsg = faked_msg_get_next();
 		if(pv_eval_str(fmsg, &newval, &defvalue)>=0) {
-			defvalue = newval;
+			sb = str_list_block_add(&_ksr_substdef_strlist, newval.s, newval.len);
+			if(sb==NULL) {
+				LM_ERR("failed to handle substdef: [%s]\n", data);
+				return -1;
+			}
+			defvalue = sb->s;
 		}
 	}
 	if(pp_define_set(defvalue.len, defvalue.s,




More information about the sr-dev mailing list