[Freeswitch-svn] [commit] r3583 - in freeswitch/trunk/src/mod/applications: mod_commands mod_dptools

Freeswitch SVN mikej at freeswitch.org
Fri Dec 8 11:31:58 EST 2006


Author: mikej
Date: Fri Dec  8 11:31:58 2006
New Revision: 3583

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

Log:
add extra input checking for valid input on some api's and functions.

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	Fri Dec  8 11:31:58 2006
@@ -162,7 +162,7 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_status_t reload_function(char *mod, switch_core_session_t *session, switch_stream_handle_t *stream)
+static switch_status_t reload_function(char *args, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
 	const char *err;
 	switch_xml_t xml_root;
@@ -214,7 +214,7 @@
 	
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
-	if (argc < 2 || argc > 4) {
+	if (switch_strlen_zero(cmd) || argc < 2 || argc > 4) {
 		stream->write_function(stream, "USAGE: %s\n", transfer_api_interface.syntax);
 	} else {
 		char *uuid = argv[0];
@@ -252,7 +252,7 @@
 	
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
-	if (argc < 1) {
+	if (switch_strlen_zero(cmd) || argc < 1) {
 		stream->write_function(stream, "USAGE: %s\n", media_api_interface.syntax);
 	} else {
 		if (!strcmp(argv[0], "off")) {
@@ -284,7 +284,7 @@
 	
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
-	if (argc < 2) {
+	if (switch_strlen_zero(cmd) || argc < 2) {
 		stream->write_function(stream, "USAGE: %s\n", broadcast_api_interface.syntax);
 	} else {
 		switch_media_flag_t flags = SMF_NONE;
@@ -320,7 +320,7 @@
 	
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
-	if (argc < 1) {
+	if (switch_strlen_zero(cmd) || argc < 1) {
 		stream->write_function(stream, "USAGE: %s\n", hold_api_interface.syntax);
 	} else {
 		if (!strcmp(argv[0], "off")) {
@@ -350,7 +350,7 @@
 	
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
-	if (argc != 2) {
+	if (switch_strlen_zero(cmd) || argc != 2) {
 		stream->write_function(stream, "USAGE: %s\n", uuid_bridge_api_interface.syntax);
 	} else {
 		if (switch_ivr_uuid_bridge(argv[0], argv[1]) != SWITCH_STATUS_SUCCESS) {
@@ -373,7 +373,7 @@
 	
 	argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
 
-	if (argc < 2) {
+	if (switch_strlen_zero(cmd) || argc < 2) {
 		stream->write_function(stream, "USAGE: %s\n", pause_api_interface.syntax);
 	} else {
 		char *uuid = argv[0];

Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	Fri Dec  8 11:31:58 2006
@@ -43,7 +43,7 @@
 	int argc;
 	char *lbuf = NULL;
 
-	if ((lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+	if (data && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
 		if (!strcasecmp(argv[0], "grammar") && argc >= 1) {
 			switch_ivr_detect_speech_load_grammar(session, argv[1], argv[2]);
 		} else if (!strcasecmp(argv[0], "nogrammar")) {
@@ -77,7 +77,7 @@
 	char *argv[4] = {0};
 	char *mydata;
 
-	if ((mydata = switch_core_session_strdup(session, data))) {
+	if (data && (mydata = switch_core_session_strdup(session, data))) {
 		if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) {
 			switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]);
 		} else {
@@ -144,7 +144,7 @@
 	channel = switch_core_session_get_channel(session);
     assert(channel != NULL);
 
-    if ((level = strdup(data))) {
+    if (data && (level = strdup(data))) {
         switch_event_types_t etype = SWITCH_LOG_DEBUG;
         
         if ((log_str = strchr(level, ' '))) {
@@ -220,7 +220,7 @@
 	int argc;
 	char *lbuf;
 
-	if ((lbuf = switch_core_session_strdup(session, data))&&(argc = switch_separate_string(lbuf, '=', argv, (sizeof(argv) / sizeof(argv[0])))) > 1) {
+	if (data && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, '=', argv, (sizeof(argv) / sizeof(argv[0])))) > 1) {
 		switch_size_t retsize;
 		switch_time_exp_t tm;
 		char date[80] = "";
@@ -238,12 +238,13 @@
 
 static switch_status_t strftime_api_function(char *fmt, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
+	
 	switch_size_t retsize;
 	switch_time_exp_t tm;
 	char date[80] = "";
 	
 	switch_time_exp_lt(&tm, switch_time_now());
-	switch_strftime(date, &retsize, sizeof(date), fmt, &tm);
+	switch_strftime(date, &retsize, sizeof(date), fmt ? fmt : "%Y-%m-%d %T", &tm);
 	stream->write_function(stream, date);
 
 	return SWITCH_STATUS_SUCCESS;
@@ -290,7 +291,7 @@
 	char *lbuf, *argv[4];
 	int argc = 0;
 
-	if ((lbuf = strdup(fmt)) && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
+	if (fmt && (lbuf = strdup(fmt)) && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
 		switch_chat_interface_t *ci;
 		
 		if ((ci = switch_loadable_module_get_chat_interface(argv[0]))) {
@@ -324,9 +325,9 @@
 static void ivr_application_function(switch_core_session_t *session, char *data)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
-	char *params = switch_core_session_strdup(session,data);
+	char *params;
 
-	if (channel != NULL && params != NULL) {
+	if (channel && data && (params = switch_core_session_strdup(session,data))) {
 		switch_xml_t cxml = NULL, cfg = NULL, xml_menus = NULL, xml_menu = NULL;
 
 		// Open the config from the xml registry



More information about the Freeswitch-svn mailing list