فهرست منبع

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 <[email protected]>
(cherry picked from commit 7c98d547996637a7bf1c7025c93142f574fe3ac9)
tsearle 4 سال پیش
والد
کامیت
be0e0fc4da
1فایلهای تغییر یافته به همراه18 افزوده شده و 2 حذف شده
  1. 18 2
      src/modules/siptrace/siptrace.c

+ 18 - 2
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_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 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_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 w_sip_trace_mode(sip_msg_t *msg, char *pmode, char *p2);
 
 
 static int siptrace_parse_uri(str* duri, dest_info_t* dst);
 static int siptrace_parse_uri(str* duri, dest_info_t* dst);
@@ -200,9 +201,9 @@ static cmd_export_t cmds[] = {
 		ANY_ROUTE},
 		ANY_ROUTE},
 	{"sip_trace", (cmd_function)w_sip_trace1, 1, fixup_siptrace, 0,
 	{"sip_trace", (cmd_function)w_sip_trace1, 1, fixup_siptrace, 0,
 		ANY_ROUTE},
 		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},
 		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},
 		ANY_ROUTE},
 	{"hlog", (cmd_function)w_hlog1, 1, fixup_spve_null, 0,
 	{"hlog", (cmd_function)w_hlog1, 1, fixup_spve_null, 0,
 		ANY_ROUTE},
 		ANY_ROUTE},
@@ -779,6 +780,21 @@ static int fixup_siptrace(void **param, int param_no)
 	return 0;
 	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;
+}
+
 
 
 /**
 /**
  *
  *