[Freeswitch-svn] [commit] r6010 - freeswitch/trunk/src/mod/applications/mod_commands

Freeswitch SVN mikej at freeswitch.org
Sat Oct 20 02:01:41 EDT 2007


Author: mikej
Date: Sat Oct 20 02:01:41 2007
New Revision: 6010

Modified:
   freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c

Log:
fix segfaults on bad api command usage MODAPP-34

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	Sat Oct 20 02:01:41 2007
@@ -333,6 +333,11 @@
 	time_t to = 0;
 	switch_core_session_t *rsession;
 	
+	if (!cmd) {
+		stream->write_function(stream, "USAGE: %s\n", TONE_DETECT_SYNTAX);
+		return SWITCH_STATUS_SUCCESS;
+	}
+
 	mydata = strdup(cmd);
 	assert(mydata != NULL);
 
@@ -989,6 +994,11 @@
 SWITCH_STANDARD_API(sched_del_function)
 {
 	uint32_t cnt = 0;
+
+	if (!cmd) {
+		stream->write_function(stream, "Invalid syntax\n");
+		return SWITCH_STATUS_SUCCESS;
+	}
 	
 	if (switch_is_digit_string(cmd)) {
 		int64_t tmp;
@@ -1010,6 +1020,11 @@
 	char *dcommand, *edata = NULL, *send = NULL, *command, *arg = NULL;
 	switch_stream_handle_t mystream = { 0 };
 	int encoded = 0, elen = 0;
+
+	if (!cmd) {
+		stream->write_function(stream, "Invalid syntax\n");
+		return SWITCH_STATUS_SUCCESS;
+	}
 	
 	if ((dcommand = strdup(cmd))) {
 		if (!strncasecmp(dcommand, "encoded ", 8)) {
@@ -1059,7 +1074,10 @@
 	char *tm = NULL, *dcmd, *group;
 	time_t when;
 
-	assert(cmd != NULL);
+	if (!cmd) {
+		stream->write_function(stream, "Invalid syntax\n");
+		return SWITCH_STATUS_SUCCESS;
+	}
 	tm = strdup(cmd);
 	assert(tm != NULL);
 



More information about the Freeswitch-svn mailing list