code analysis and error checking.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7568 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2008-02-09 05:16:58 +00:00
parent 8368c5ed18
commit 18a0b7a42a
7 changed files with 25 additions and 21 deletions

View File

@ -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

View File

@ -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);

View File

@ -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];

View File

@ -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,

View File

@ -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);

View File

@ -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

View File

@ -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";
}