[commit] r7568 - in freeswitch/trunk/src: include mod/applications/mod_commands mod/applications/mod_conference mod/endpoints/mod_dingaling mod/endpoints/mod_portaudio mod/endpoints/mod_sofia
Author: mikej Date: Sat Feb 9 00:16:58 2008 New Revision: 7568 Modified: freeswitch/trunk/src/include/switch_event.h freeswitch/trunk/src/include/switch_types.h freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Log: code analysis and error checking. Modified: freeswitch/trunk/src/include/switch_event.h ============================================================================== --- freeswitch/trunk/src/include/switch_event.h (original) +++ freeswitch/trunk/src/include/switch_event.h Sat Feb 9 00:16:58 2008 @@ -156,7 +156,7 @@ \param header_name the name of the header to read \return the value of the requested header */ -SWITCH_DECLARE(char *) switch_event_get_header(switch_event_t *event, char *header_name); +_Ret_opt_z_ SWITCH_DECLARE(char *) switch_event_get_header(switch_event_t *event, char *header_name); /*! \brief Retrieve the body value from an event Modified: freeswitch/trunk/src/include/switch_types.h ============================================================================== --- freeswitch/trunk/src/include/switch_types.h (original) +++ freeswitch/trunk/src/include/switch_types.h Sat Feb 9 00:16:58 2008 @@ -1206,9 +1206,9 @@ typedef switch_status_t (*switch_stream_handle_write_function_t) (switch_stream_handle_t *handle, const char *fmt, ...); typedef switch_status_t (*switch_stream_handle_raw_write_function_t) (switch_stream_handle_t *handle, uint8_t *data, switch_size_t datalen); -typedef switch_status_t (*switch_api_function_t) (const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream); +typedef switch_status_t (*switch_api_function_t) (_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session, _In_ switch_stream_handle_t *stream); -#define SWITCH_STANDARD_API(name) static switch_status_t name (const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream) +#define SWITCH_STANDARD_API(name) static switch_status_t name (_In_opt_z_ const char *cmd, _In_opt_ switch_core_session_t *session, _In_ switch_stream_handle_t *stream) typedef switch_status_t (*switch_input_callback_function_t) (switch_core_session_t *session, void *input, switch_input_type_t input_type, void *buf, unsigned int buflen); 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 Feb 9 00:16:58 2008 @@ -723,7 +723,7 @@ dp = argv[2]; context = argv[3]; - if (!(tsession = switch_core_session_locate(tuuid))) { + if (switch_strlen_zero(tuuid) || !(tsession = switch_core_session_locate(tuuid))) { stream->write_function(stream, "-ERR No Such Channel!\n"); goto done; } @@ -885,7 +885,7 @@ argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (switch_strlen_zero(cmd) || argc < 2 || argc > 5) { + if (switch_strlen_zero(cmd) || argc < 2 || argc > 5 || switch_strlen_zero(argv[0])) { stream->write_function(stream, "-USAGE: %s\n", SCHED_TRANSFER_SYNTAX); } else { char *uuid = argv[1]; @@ -928,7 +928,7 @@ argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (switch_strlen_zero(cmd) || argc < 1) { + if (switch_strlen_zero(cmd) || argc < 1 || switch_strlen_zero(argv[0])) { stream->write_function(stream, "-USAGE: %s\n", SCHED_HANGUP_SYNTAX); } else { char *uuid = argv[1]; @@ -974,7 +974,7 @@ argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (switch_strlen_zero(cmd) || argc < 1) { + if (switch_strlen_zero(cmd) || argc < 1 || switch_strlen_zero(argv[0])) { stream->write_function(stream, "-USAGE: %s\n", MEDIA_SYNTAX); } else { if (!strcasecmp(argv[0], "off")) { @@ -1049,7 +1049,7 @@ argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (switch_strlen_zero(cmd) || argc < 3) { + if (switch_strlen_zero(cmd) || argc < 3 || switch_strlen_zero(argv[0])) { stream->write_function(stream, "-USAGE: %s\n", SCHED_BROADCAST_SYNTAX); } else { switch_media_flag_t flags = SMF_NONE; @@ -1096,7 +1096,7 @@ argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (switch_strlen_zero(cmd) || argc < 1) { + if (switch_strlen_zero(cmd) || argc < 1 || switch_strlen_zero(argv[0])) { stream->write_function(stream, "-USAGE: %s\n", HOLD_SYNTAX); } else { if (!strcasecmp(argv[0], "off")) { @@ -1304,7 +1304,7 @@ argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); } - if (switch_strlen_zero(cmd) || argc < 2) { + if (switch_strlen_zero(cmd) || argc < 2 || switch_strlen_zero(argv[0])) { stream->write_function(stream, "-USAGE: %s\n", PAUSE_SYNTAX); } else { char *uuid = argv[0]; @@ -1930,7 +1930,7 @@ if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - if (argc == 3) { + if (argc == 3 && !switch_strlen_zero(argv[0])) { char *uuid = argv[0]; char *var_name = argv[1]; char *var_value = argv[2]; @@ -1976,7 +1976,7 @@ if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - if (argc >= 2) { + if (argc >= 2 && !switch_strlen_zero(argv[0])) { char *uuid = argv[0]; char *var_name = argv[1]; const char *var_value = NULL; @@ -2026,7 +2026,7 @@ if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - if (argc >= 0) { + if (argc >= 0 && !switch_strlen_zero(argv[0])) { char *uuid = argv[0]; char *format = argv[1]; @@ -2085,7 +2085,7 @@ if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { argc = switch_separate_string(mycmd, '=', argv, (sizeof(argv) / sizeof(argv[0]))); - if (argc > 0) { + if (argc > 0 && !switch_strlen_zero(argv[0])) { char *var_name = argv[0]; char *var_value = argv[1]; Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c ============================================================================== --- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original) +++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Sat Feb 9 00:16:58 2008 @@ -314,7 +314,7 @@ static switch_status_t conference_play_file(conference_obj_t * conference, char *file, uint32_t leadin, switch_channel_t *channel, uint8_t async); static switch_status_t conference_say(conference_obj_t * conference, const char *text, uint32_t leadin); static void conference_list(conference_obj_t * conference, switch_stream_handle_t *stream, char *delim); -static switch_status_t conf_api_main(const char *buf, switch_core_session_t *session, switch_stream_handle_t *stream); +SWITCH_STANDARD_API(conf_api_main); static switch_status_t audio_bridge_on_ring(switch_core_session_t *session); static switch_status_t conference_outcall(conference_obj_t * conference, char *conference_name, Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Sat Feb 9 00:16:58 2008 @@ -195,10 +195,10 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string); SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string); -static switch_status_t dl_login(const char *arg, switch_core_session_t *session, switch_stream_handle_t *stream); -static switch_status_t dl_logout(const char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream); -static switch_status_t dl_pres(const char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream); -static switch_status_t dl_debug(const char *profile_name, switch_core_session_t *session, switch_stream_handle_t *stream); +SWITCH_STANDARD_API(dl_login); +SWITCH_STANDARD_API(dl_logout); +SWITCH_STANDARD_API(dl_pres); +SWITCH_STANDARD_API(dl_debug); static switch_status_t channel_on_init(switch_core_session_t *session); static switch_status_t channel_on_hangup(switch_core_session_t *session); static switch_status_t channel_on_ring(switch_core_session_t *session); Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c Sat Feb 9 00:16:58 2008 @@ -156,7 +156,7 @@ static switch_status_t load_config(void); static int get_dev_by_name(char *name, int in); static int get_dev_by_number(int number, int in); -static switch_status_t pa_cmd(const char *dest, switch_core_session_t *session, switch_stream_handle_t *stream); +SWITCH_STANDARD_API(pa_cmd); /* State methods they get called when the state changes to the specific state Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c ============================================================================== --- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original) +++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Sat Feb 9 00:16:58 2008 @@ -364,10 +364,14 @@ char *rpid = switch_event_get_header(event, "orig-rpid"); char *call_id = switch_event_get_header(event, "orig-call-id"); char *user_agent = switch_event_get_header(event, "user-agent"); - long expires = (long) switch_timestamp(NULL) + atol(exp_str); + long expires = (long) switch_timestamp(NULL); char *profile_name = switch_event_get_header(event, "orig-profile-name"); sofia_profile_t *profile = NULL; + if (exp_str) { + expires += atol(exp_str); + } + if (!rpid) { rpid = "unknown"; }
participants (1)
-
Freeswitch SVN