[sr-dev] git:master:7c98d547: modules/siptrace: fix regression preventing variables to be used (#2588)

GitHub noreply at github.com
Wed Dec 16 21:47:16 CET 2020


Module: kamailio
Branch: master
Commit: 7c98d547996637a7bf1c7025c93142f574fe3ac9
URL: https://github.com/kamailio/kamailio/commit/7c98d547996637a7bf1c7025c93142f574fe3ac9

Author: tsearle <tsearle at gmail.com>
Committer: GitHub <noreply at github.com>
Date: 2020-12-16T21:47:11+01:00

modules/siptrace: fix regression preventing variables to be used (#2588)

* modules/siptrace: fix regression preventing variables to be used

Commit fa7eb2a switched the 2 parameter version of sip_trace from
using the builtin fixup_spve_spve to the custom fixup method to
using the custom fixup_siptrace. As it is a custom fixup method,
the corresponding free method can not be auto-detected causing the
config parser to require the parameters to be a constant.  This
patch adds a free method, allowing variables to be once again passed
as the 2nd parameter of this method (as well as fixing a memory leak
for the 3rd parameter).

* change free for parameter 3

Co-authored-by: Torrey Searle <tsearle at voxbone.com>

---

Modified: src/modules/siptrace/siptrace.c

---

Diff:  https://github.com/kamailio/kamailio/commit/7c98d547996637a7bf1c7025c93142f574fe3ac9.diff
Patch: https://github.com/kamailio/kamailio/commit/7c98d547996637a7bf1c7025c93142f574fe3ac9.patch

---

diff --git a/src/modules/siptrace/siptrace.c b/src/modules/siptrace/siptrace.c
index 2e8e690ac0..e9c44ec548 100644
--- a/src/modules/siptrace/siptrace.c
+++ b/src/modules/siptrace/siptrace.c
@@ -91,6 +91,7 @@ static int w_sip_trace1(struct sip_msg *, char *dest, char *p2);
 static int w_sip_trace2(struct sip_msg *, char *dest, char *correlation_id);
 static int w_sip_trace3(struct sip_msg *, char *dest, char *correlation_id, char *trace_type);
 static int fixup_siptrace(void **param, int param_no);
+static int fixup_free_siptrace(void **param, int param_no);
 static int w_sip_trace_mode(sip_msg_t *msg, char *pmode, char *p2);
 
 static int siptrace_parse_uri(str* duri, dest_info_t* dst);
@@ -203,9 +204,9 @@ static cmd_export_t cmds[] = {
 		ANY_ROUTE},
 	{"sip_trace", (cmd_function)w_sip_trace1, 1, fixup_siptrace, 0,
 		ANY_ROUTE},
-	{"sip_trace", (cmd_function)w_sip_trace2, 2, fixup_siptrace, 0,
+	{"sip_trace", (cmd_function)w_sip_trace2, 2, fixup_siptrace, fixup_free_siptrace,
 		ANY_ROUTE},
-	{"sip_trace", (cmd_function)w_sip_trace3, 3, fixup_siptrace, 0,
+	{"sip_trace", (cmd_function)w_sip_trace3, 3, fixup_siptrace, fixup_free_siptrace,
 		ANY_ROUTE},
 	{"hlog", (cmd_function)w_hlog1, 1, fixup_spve_null, 0,
 		ANY_ROUTE},
@@ -785,6 +786,21 @@ static int fixup_siptrace(void **param, int param_no)
 	return 0;
 }
 
+static int fixup_free_siptrace(void **param, int param_no)
+{
+	if (param_no == 1 || param_no == 2) {
+		/* correlation id */
+		return fixup_free_spve_all(param, param_no);
+	} if (param_no == 3) {
+		/* tracing type; string only */
+		if (*param) {
+			pkg_free(*param);
+		}
+	}
+
+	return 0;
+}
+
 
 /**
  *




More information about the sr-dev mailing list