Browse code

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@voxbone.com>
(cherry picked from commit 7c98d547996637a7bf1c7025c93142f574fe3ac9)

tsearle authored on 16/12/2020 20:47:11 • Henning Westerholt committed on 21/12/2020 15:31:26
Showing 1 changed files
... ...
@@ -87,6 +87,7 @@ static int w_sip_trace1(struct sip_msg *, char *dest, char *p2);
87 87
 static int w_sip_trace2(struct sip_msg *, char *dest, char *correlation_id);
88 88
 static int w_sip_trace3(struct sip_msg *, char *dest, char *correlation_id, char *trace_type);
89 89
 static int fixup_siptrace(void **param, int param_no);
90
+static int fixup_free_siptrace(void **param, int param_no);
90 91
 static int w_sip_trace_mode(sip_msg_t *msg, char *pmode, char *p2);
91 92
 
92 93
 static int parse_siptrace_uri(str* duri, dest_info_t* dst);
... ...
@@ -191,9 +192,9 @@ static cmd_export_t cmds[] = {
191 192
 		ANY_ROUTE},
192 193
 	{"sip_trace", (cmd_function)w_sip_trace1, 1, fixup_siptrace, 0,
193 194
 		ANY_ROUTE},
194
-	{"sip_trace", (cmd_function)w_sip_trace2, 2, fixup_siptrace, 0,
195
+	{"sip_trace", (cmd_function)w_sip_trace2, 2, fixup_siptrace, fixup_free_siptrace,
195 196
 		ANY_ROUTE},
196
-	{"sip_trace", (cmd_function)w_sip_trace3, 3, fixup_siptrace, 0,
197
+	{"sip_trace", (cmd_function)w_sip_trace3, 3, fixup_siptrace, fixup_free_siptrace,
197 198
 		ANY_ROUTE},
198 199
 	{"hlog", (cmd_function)w_hlog1, 1, fixup_spve_null, 0,
199 200
 		ANY_ROUTE},
... ...
@@ -754,6 +755,21 @@ static int fixup_siptrace(void **param, int param_no)
754 755
 	return 0;
755 756
 }
756 757
 
758
+static int fixup_free_siptrace(void **param, int param_no)
759
+{
760
+	if (param_no == 1 || param_no == 2) {
761
+		/* correlation id */
762
+		return fixup_free_spve_all(param, param_no);
763
+	} if (param_no == 3) {
764
+		/* tracing type; string only */
765
+		if (*param) {
766
+			pkg_free(*param);
767
+		}
768
+	}
769
+
770
+	return 0;
771
+}
772
+
757 773
 
758 774
 /**
759 775
  *