diff --git a/src/include/switch_event.h b/src/include/switch_event.h index a2085acf2b..9a208d0587 100644 --- a/src/include/switch_event.h +++ b/src/include/switch_event.h @@ -156,7 +156,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_set_priority(switch_event_t *event, \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 diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 957522bc54..df9d01c982 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1206,9 +1206,9 @@ typedef struct switch_stream_handle switch_stream_handle_t; 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); diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index aeb2735ca8..6edf8c52a0 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -723,7 +723,7 @@ SWITCH_STANDARD_API(transfer_function) 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 @@ SWITCH_STANDARD_API(sched_transfer_function) 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 @@ SWITCH_STANDARD_API(sched_hangup_function) 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 @@ SWITCH_STANDARD_API(uuid_media_function) 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 @@ SWITCH_STANDARD_API(sched_broadcast_function) 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 @@ SWITCH_STANDARD_API(uuid_hold_function) 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 @@ SWITCH_STANDARD_API(pause_function) 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 @@ SWITCH_STANDARD_API(uuid_setvar_function) 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 @@ SWITCH_STANDARD_API(uuid_getvar_function) 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 @@ SWITCH_STANDARD_API(uuid_dump_function) 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 @@ SWITCH_STANDARD_API(global_setvar_function) 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]; diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index f0bd147026..a8d616fabc 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -314,7 +314,7 @@ static uint32_t conference_stop_file(conference_obj_t * conference, file_stop_t 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, diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index dabaca046f..41237d8937 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -195,10 +195,10 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan); 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); diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index 5e858cab3b..fe51bdadb6 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -156,7 +156,7 @@ static int dump_info(void); 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 diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index b415225b9a..662c7af62c 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -364,10 +364,14 @@ void event_handler(switch_event_t *event) 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"; }