提交 2847d1c0 authored 作者: Michael Jerris's avatar Michael Jerris

more error checking.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6954 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 0db04513
差异被折叠。
......@@ -814,8 +814,9 @@ SWITCH_STANDARD_API(tone_detect_session_function)
mydata = strdup(cmd);
switch_assert(mydata != NULL);
if ((argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]))) < 3) {
if ((argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]))) < 3 || !argv[0]) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "-ERR INVALID ARGS!\n");
return SWITCH_STATUS_SUCCESS;
}
......@@ -1206,15 +1207,15 @@ SWITCH_STANDARD_API(session_record_function)
path = argv[2];
limit = argv[3] ? atoi(argv[3]) : 0;
if (switch_strlen_zero(uuid) || switch_strlen_zero(action) || switch_strlen_zero(path)) {
goto usage;
}
if (!(rsession = switch_core_session_locate(uuid))) {
stream->write_function(stream, "-ERR Cannot locate session!\n");
return SWITCH_STATUS_SUCCESS;
}
if (switch_strlen_zero(action) || switch_strlen_zero(path)) {
goto usage;
}
if (!strcasecmp(action, "start")) {
switch_ivr_record_session(rsession, path, limit, NULL);
} else if (!strcasecmp(action, "stop")) {
......@@ -1273,15 +1274,15 @@ SWITCH_STANDARD_API(session_displace_function)
limit = argv[3] ? atoi(argv[3]) : 0;
flags = argv[4];
if (switch_strlen_zero(uuid) || switch_strlen_zero(action) || switch_strlen_zero(path)) {
goto usage;
}
if (!(rsession = switch_core_session_locate(uuid))) {
stream->write_function(stream, "-ERR Cannot locate session!\n");
return SWITCH_STATUS_SUCCESS;
}
if (switch_strlen_zero(action) || switch_strlen_zero(path)) {
goto usage;
}
if (!strcasecmp(action, "start")) {
switch_ivr_displace_session(rsession, path, limit, flags);
} else if (!strcasecmp(action, "stop")) {
......
......@@ -4599,63 +4599,63 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m
var = buf;
}
if (!strcasecmp(var, "rate")) {
if (!strcasecmp(var, "rate") && !switch_strlen_zero(val)) {
rate_name = val;
} else if (!strcasecmp(var, "domain")) {
} else if (!strcasecmp(var, "domain") && !switch_strlen_zero(val)) {
domain = val;
} else if (!strcasecmp(var, "interval")) {
} else if (!strcasecmp(var, "interval") && !switch_strlen_zero(val)) {
interval_name = val;
} else if (!strcasecmp(var, "timer-name")) {
} else if (!strcasecmp(var, "timer-name") && !switch_strlen_zero(val)) {
timer_name = val;
} else if (!strcasecmp(var, "tts-engine")) {
} else if (!strcasecmp(var, "tts-engine") && !switch_strlen_zero(val)) {
tts_engine = val;
} else if (!strcasecmp(var, "tts-voice")) {
} else if (!strcasecmp(var, "tts-voice") && !switch_strlen_zero(val)) {
tts_voice = val;
} else if (!strcasecmp(var, "enter-sound")) {
} else if (!strcasecmp(var, "enter-sound") && !switch_strlen_zero(val)) {
enter_sound = val;
} else if (!strcasecmp(var, "exit-sound")) {
} else if (!strcasecmp(var, "exit-sound") && !switch_strlen_zero(val)) {
exit_sound = val;
} else if (!strcasecmp(var, "alone-sound")) {
} else if (!strcasecmp(var, "alone-sound") && !switch_strlen_zero(val)) {
alone_sound = val;
} else if (!strcasecmp(var, "perpetual-sound")) {
} else if (!strcasecmp(var, "perpetual-sound") && !switch_strlen_zero(val)) {
perpetual_sound = val;
} else if (!strcasecmp(var, "moh-sound")) {
} else if (!strcasecmp(var, "moh-sound") && !switch_strlen_zero(val)) {
moh_sound = val;
} else if (!strcasecmp(var, "ack-sound")) {
} else if (!strcasecmp(var, "ack-sound") && !switch_strlen_zero(val)) {
ack_sound = val;
} else if (!strcasecmp(var, "nack-sound")) {
} else if (!strcasecmp(var, "nack-sound") && !switch_strlen_zero(val)) {
nack_sound = val;
} else if (!strcasecmp(var, "muted-sound")) {
} else if (!strcasecmp(var, "muted-sound") && !switch_strlen_zero(val)) {
muted_sound = val;
} else if (!strcasecmp(var, "unmuted-sound")) {
} else if (!strcasecmp(var, "unmuted-sound") && !switch_strlen_zero(val)) {
unmuted_sound = val;
} else if (!strcasecmp(var, "locked-sound")) {
} else if (!strcasecmp(var, "locked-sound") && !switch_strlen_zero(val)) {
locked_sound = val;
} else if (!strcasecmp(var, "is-locked-sound")) {
} else if (!strcasecmp(var, "is-locked-sound") && !switch_strlen_zero(val)) {
is_locked_sound = val;
} else if (!strcasecmp(var, "is-unlocked-sound")) {
} else if (!strcasecmp(var, "is-unlocked-sound") && !switch_strlen_zero(val)) {
is_unlocked_sound = val;
} else if (!strcasecmp(var, "member-flags")) {
} else if (!strcasecmp(var, "member-flags") && !switch_strlen_zero(val)) {
member_flags = val;
} else if (!strcasecmp(var, "kicked-sound")) {
} else if (!strcasecmp(var, "kicked-sound") && !switch_strlen_zero(val)) {
kicked_sound = val;
} else if (!strcasecmp(var, "pin")) {
} else if (!strcasecmp(var, "pin") && !switch_strlen_zero(val)) {
pin = val;
} else if (!strcasecmp(var, "pin-sound")) {
} else if (!strcasecmp(var, "pin-sound") && !switch_strlen_zero(val)) {
pin_sound = val;
} else if (!strcasecmp(var, "bad-pin-sound")) {
} else if (!strcasecmp(var, "bad-pin-sound") && !switch_strlen_zero(val)) {
bad_pin_sound = val;
} else if (!strcasecmp(var, "energy-level")) {
} else if (!strcasecmp(var, "energy-level") && !switch_strlen_zero(val)) {
energy_level = val;
} else if (!strcasecmp(var, "caller-id-name")) {
} else if (!strcasecmp(var, "caller-id-name") && !switch_strlen_zero(val)) {
caller_id_name = val;
} else if (!strcasecmp(var, "caller-id-number")) {
} else if (!strcasecmp(var, "caller-id-number") && !switch_strlen_zero(val)) {
caller_id_number = val;
} else if (!strcasecmp(var, "caller-controls")) {
} else if (!strcasecmp(var, "caller-controls") && !switch_strlen_zero(val)) {
caller_controls = val;
} else if (!strcasecmp(var, "sound-prefix")) {
} else if (!strcasecmp(var, "sound-prefix") && !switch_strlen_zero(val)) {
sound_prefix = val;
} else if (!strcasecmp(var, "max-members")) {
} else if (!strcasecmp(var, "max-members") && !switch_strlen_zero(val)) {
errno = 0; // sanity first
max_members = strtol(val, NULL, 0); // base 0 lets 0x... for hex 0... for octal and base 10 otherwise through
if (errno == ERANGE || errno == EINVAL || max_members < 0 || max_members == 1) {
......@@ -4664,9 +4664,9 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m
max_members = 0; // set to 0 to disable max counts
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "max-members %s is invalid, not setting a limit\n", val);
}
} else if (!strcasecmp(var, "max-members-sound")) {
} else if (!strcasecmp(var, "max-members-sound") && !switch_strlen_zero(val)) {
maxmember_sound = val;
} else if (!strcasecmp(var, "anounce-count")) {
} else if (!strcasecmp(var, "anounce-count") && !switch_strlen_zero(val)) {
errno = 0; // safety first
anounce_count = strtol(val, NULL, 0);
if (errno == ERANGE || errno == EINVAL) {
......@@ -4728,9 +4728,15 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m
/* initialize the conference object with settings from the specified profile */
conference->pool = pool;
conference->profile_name = switch_core_strdup(conference->pool, switch_xml_attr_soft(cfg.profile, "name"));
conference->timer_name = switch_core_strdup(conference->pool, timer_name);
conference->tts_engine = switch_core_strdup(conference->pool, tts_engine);
conference->tts_voice = switch_core_strdup(conference->pool, tts_voice);
if (timer_name) {
conference->timer_name = switch_core_strdup(conference->pool, timer_name);
}
if (tts_engine) {
conference->tts_engine = switch_core_strdup(conference->pool, tts_engine);
}
if (tts_voice) {
conference->tts_voice = switch_core_strdup(conference->pool, tts_voice);
}
conference->caller_id_name = switch_core_strdup(conference->pool, caller_id_name);
conference->caller_id_number = switch_core_strdup(conference->pool, caller_id_number);
......
......@@ -461,7 +461,7 @@ static switch_status_t load_config(void)
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "invalid threshold value [%s] must be between 0 and 1000 ms\n", val);
}
} else if (!strcasecmp(var, "tone-spec")) {
} else if (!strcasecmp(var, "tone-spec") && !switch_strlen_zero(val)) {
tone_spec = val;
} else if (!strcasecmp(var, "digit-timeout")) {
int tmp = 0;
......
......@@ -1335,14 +1335,14 @@ static switch_status_t channel_waitfor_write(switch_core_session_t *session, int
}
static switch_status_t channel_send_dtmf(switch_core_session_t *session, char *dtmf)
static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
{
struct private_object *tech_pvt = NULL;
tech_pvt = switch_core_session_get_private(session);
switch_assert(tech_pvt != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF [%s]\n", dtmf);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF [%c]\n", dtmf->digit);
return switch_rtp_queue_rfc2833(tech_pvt->rtp_session, dtmf);
......@@ -1627,7 +1627,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
char *profile_name;
char *callto;
char idbuf[1024];
char *full_id;
char *full_id = NULL;
char sess_id[11] = "";
char *dnis = NULL;
char workspace[1024] = "";
......@@ -1716,7 +1716,9 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
tech_pvt->recip = switch_core_session_strdup(*new_session, full_id);
tech_pvt->dnis = switch_core_session_strdup(*new_session, dnis);
if (dnis) {
tech_pvt->dnis = switch_core_session_strdup(*new_session, dnis);
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
......@@ -1956,25 +1958,25 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val)
#endif
} else if (!strcasecmp(var, "use-rtp-timer") && switch_true(val)) {
switch_set_flag(profile, TFLAG_TIMER);
} else if (!strcasecmp(var, "dialplan")) {
} else if (!strcasecmp(var, "dialplan") && !switch_strlen_zero(val)) {
profile->dialplan = switch_core_strdup(module_pool, val);
#ifdef AUTO_REPLY // gotta fix looping on this
} else if (!strcasecmp(var, "auto-reply")) {
profile->auto_reply = switch_core_strdup(module_pool, val);
#endif
} else if (!strcasecmp(var, "name")) {
} else if (!strcasecmp(var, "name") && !switch_strlen_zero(val)) {
profile->name = switch_core_strdup(module_pool, val);
} else if (!strcasecmp(var, "message")) {
} else if (!strcasecmp(var, "message") && !switch_strlen_zero(val)) {
profile->message = switch_core_strdup(module_pool, val);
} else if (!strcasecmp(var, "rtp-ip")) {
profile->ip = switch_core_strdup(module_pool, strcasecmp(switch_str_nil(val), "auto") ? switch_str_nil(val) : globals.guess_ip);
} else if (!strcasecmp(var, "ext-rtp-ip")) {
profile->extip = switch_core_strdup(module_pool, strcasecmp(switch_str_nil(val), "auto") ? switch_str_nil(val) : globals.guess_ip);
} else if (!strcasecmp(var, "server")) {
} else if (!strcasecmp(var, "server") && !switch_strlen_zero(val)) {
profile->server = switch_core_strdup(module_pool, val);
} else if (!strcasecmp(var, "rtp-timer-name")) {
} else if (!strcasecmp(var, "rtp-timer-name") && !switch_strlen_zero(val)) {
profile->timer_name = switch_core_strdup(module_pool, val);
} else if (!strcasecmp(var, "lanaddr")) {
} else if (!strcasecmp(var, "lanaddr") && !switch_strlen_zero(val)) {
profile->lanaddr = switch_core_strdup(module_pool, val);
} else if (!strcasecmp(var, "tls")) {
if (switch_true(val)) {
......@@ -1986,11 +1988,11 @@ static void set_profile_val(mdl_profile_t *profile, char *var, char *val)
} else if (val && !strcasecmp(val, "md5")) {
profile->user_flags |= LDL_FLAG_SASL_MD5;
}
} else if (!strcasecmp(var, "exten")) {
} else if (!strcasecmp(var, "exten") && !switch_strlen_zero(val)) {
profile->exten = switch_core_strdup(module_pool, val);
} else if (!strcasecmp(var, "context")) {
} else if (!strcasecmp(var, "context") && !switch_strlen_zero(val)) {
profile->context = switch_core_strdup(module_pool, val);
} else if (!strcasecmp(var, "auto-login")) {
} else if (!strcasecmp(var, "auto-login") && !switch_strlen_zero(val)) {
if (switch_true(val)) {
switch_set_flag(profile, TFLAG_AUTO);
}
......
......@@ -176,9 +176,9 @@ static switch_status_t de_say_general_count(switch_core_session_t *session,
char sbuf[13] = "";
switch_status_t status;
assert(session != NULL);
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_assert(channel != NULL);
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
......@@ -426,9 +426,9 @@ static switch_status_t de_say_money(switch_core_session_t *session, char *tosay,
char *dollars = NULL;
char *cents = NULL;
assert(session != NULL);
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_assert(channel != NULL);
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
......
......@@ -176,9 +176,9 @@ static switch_status_t en_say_general_count(switch_core_session_t *session,
char sbuf[13] = "";
switch_status_t status;
assert(session != NULL);
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_assert(channel != NULL);
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
......@@ -426,9 +426,9 @@ static switch_status_t en_say_money(switch_core_session_t *session, char *tosay,
char *dollars = NULL;
char *cents = NULL;
assert(session != NULL);
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_assert(channel != NULL);
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
......
......@@ -176,9 +176,9 @@ static switch_status_t es_say_general_count(switch_core_session_t *session,
char sbuf[13] = "";
switch_status_t status;
assert(session != NULL);
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_assert(channel != NULL);
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
......@@ -426,9 +426,9 @@ static switch_status_t es_say_money(switch_core_session_t *session, char *tosay,
char *dollars = NULL;
char *cents = NULL;
assert(session != NULL);
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_assert(channel != NULL);
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
......
......@@ -176,9 +176,9 @@ static switch_status_t fr_say_general_count(switch_core_session_t *session,
char sbuf[13] = "";
switch_status_t status;
assert(session != NULL);
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_assert(channel != NULL);
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
......@@ -426,9 +426,9 @@ static switch_status_t fr_say_money(switch_core_session_t *session, char *tosay,
char *dollars = NULL;
char *cents = NULL;
assert(session != NULL);
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_assert(channel != NULL);
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
......
......@@ -176,9 +176,9 @@ static switch_status_t it_say_general_count(switch_core_session_t *session,
char sbuf[13] = "";
switch_status_t status;
assert(session != NULL);
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_assert(channel != NULL);
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
......@@ -426,9 +426,9 @@ static switch_status_t it_say_money(switch_core_session_t *session, char *tosay,
char *dollars = NULL;
char *cents = NULL;
assert(session != NULL);
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_assert(channel != NULL);
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
......
......@@ -176,9 +176,9 @@ static switch_status_t nl_say_general_count(switch_core_session_t *session,
char sbuf[13] = "";
switch_status_t status;
assert(session != NULL);
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_assert(channel != NULL);
if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
......@@ -426,9 +426,9 @@ static switch_status_t nl_say_money(switch_core_session_t *session, char *tosay,
char *dollars = NULL;
char *cents = NULL;
assert(session != NULL);
switch_assert(session != NULL);
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_assert(channel != NULL);
if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
......
......@@ -564,7 +564,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
if (caller_profile_override) {
new_profile = switch_caller_profile_dup(pool, caller_profile_override);
new_profile->destination_number = switch_core_strdup(new_profile->pool, chan_data);
new_profile->destination_number = switch_core_strdup(new_profile->pool, switch_str_nil(chan_data));
new_profile->uuid = SWITCH_BLANK_STRING;
new_profile->chan_name = SWITCH_BLANK_STRING;
} else {
......
......@@ -279,7 +279,7 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
switch_stun_packet_attribute_t *attr;
switch_size_t bytes = 0;
char username[33] = { 0 };
char rip[16];
char rip[16] = { 0 };
uint16_t rport = 0;
switch_time_t started = 0;
unsigned int elapsed = 0;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论