don't strstr on null/blank strings.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7027 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-12-30 00:22:51 +00:00
parent 33bd22a308
commit 6c25cb4136
9 changed files with 13 additions and 13 deletions

View File

@ -50,9 +50,9 @@ SWITCH_BEGIN_EXTERN_C
codec->implementation->samples_per_second, \
codec->implementation->microseconds_per_frame / 1000)
#ifdef WIN32
#define switch_is_file_path(file) (*file == '\\' || *(file +1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR))
#define switch_is_file_path(file) (file && (*file == '\\' || *(file +1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR)))
#else
#define switch_is_file_path(file) ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR))
#define switch_is_file_path(file) (file && ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR)))
#endif
SWITCH_DECLARE(switch_status_t) switch_b64_encode(unsigned char *in, switch_size_t ilen, unsigned char *out, switch_size_t olen);

View File

@ -3498,9 +3498,9 @@ switch_status_t conf_api_dispatch(conference_obj_t * conference, switch_stream_h
const char *modified_cmdline = cmdline;
const char *cmd = conf_api_sub_commands[i].pname;
if ((start_text = strstr(modified_cmdline, cmd))) {
if (!switch_strlen_zero(modified_cmdline) && (start_text = strstr(modified_cmdline, cmd))) {
modified_cmdline = start_text + strlen(cmd);
while (modified_cmdline && *modified_cmdline && (*modified_cmdline == ' ' || *modified_cmdline == '\t')) {
while (modified_cmdline && (*modified_cmdline == ' ' || *modified_cmdline == '\t')) {
modified_cmdline++;
}
}

View File

@ -1016,7 +1016,7 @@ static int get_dev_by_name(char *name, int in)
if (switch_strlen_zero(name)) {
match = 1;
} else if (strstr(pdi->name, name)) {
} else if (pdi && pdi->name && strstr(pdi->name, name)) {
match = 1;
}

View File

@ -1275,7 +1275,7 @@ void sofia_presence_handle_sip_i_message(int status,
const char *subject = "n/a";
char *msg = NULL;
if (sip->sip_content_type) {
if (sip->sip_content_type && !switch_strlen_zero(sip->sip_content_type->c_subtype)) {
if (strstr(sip->sip_content_type->c_subtype, "composing")) {
return;
}

View File

@ -1027,7 +1027,7 @@ static switch_status_t load_modules(void)
if ((mods = switch_xml_child(cfg, "modules"))) {
for (ld = switch_xml_child(mods, "load"); ld; ld = ld->next) {
const char *val = switch_xml_attr_soft(ld, "module");
if (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT)) {
if (!switch_strlen_zero(val) && strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val);
continue;
}

View File

@ -68,7 +68,7 @@ SWITCH_DECLARE(int) switch_config_open_file(switch_config_t * cfg, char *file_pa
cfg->path = path;
while (switch_config_next_pair(cfg, &var, &val)) {
if ((cfg->sectno != last) && !strcmp(cfg->section, file_path)) {
if (file_path && (cfg->sectno != last) && !strcmp(cfg->section, file_path)) {
cfg->lockto = cfg->sectno;
return 1;
}

View File

@ -695,7 +695,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
timer_name = switch_channel_get_variable(channel, "timer_name");
if (!file) {
if (switch_strlen_zero(file)) {
status = SWITCH_STATUS_FALSE;
goto end;
}

View File

@ -983,7 +983,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
if ((mods = switch_xml_child(cfg, "modules"))) {
for (ld = switch_xml_child(mods, "load"); ld; ld = ld->next) {
const char *val = switch_xml_attr_soft(ld, "module");
if (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT)) {
if (switch_strlen_zero(val) || (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val);
continue;
}
@ -1003,7 +1003,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
if ((mods = switch_xml_child(cfg, "modules"))) {
for (ld = switch_xml_child(mods, "load"); ld; ld = ld->next) {
const char *val = switch_xml_attr_soft(ld, "module");
if (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT)) {
if (switch_strlen_zero(val) || (strchr(val, '.') && !strstr(val, ext) && !strstr(val, EXT))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val);
continue;
}
@ -1043,7 +1043,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
continue;
}
if (!strstr(fname, ext) && !strstr(fname, EXT)) {
if (switch_strlen_zero(fname) || (!strstr(fname, ext) && !strstr(fname, EXT))) {
continue;
}

View File

@ -1402,7 +1402,7 @@ SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *key,
if (user_name) {
if (strstr(xtra_params, "mailbox")) {
if (!switch_strlen_zero(xtra_params) && strstr(xtra_params, "mailbox")) {
if ((*user = switch_xml_find_child(*domain, "user", "mailbox", user_name))) {
return SWITCH_STATUS_SUCCESS;
}