bounds checks and scope masked var names.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6844 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-12-17 22:52:32 +00:00
parent 15d12ce20a
commit 577afaf6f6
3 changed files with 20 additions and 10 deletions

View File

@ -635,9 +635,11 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
switch_assert(channel != NULL); switch_assert(channel != NULL);
switch_assert(state <= CS_DONE);
switch_mutex_lock(channel->flag_mutex); switch_mutex_lock(channel->flag_mutex);
last_state = channel->state; last_state = channel->state;
switch_assert(last_state <= CS_DONE);
if (last_state == state) { if (last_state == state) {
goto done; goto done;
@ -1498,19 +1500,19 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
char *expanded = NULL; char *expanded = NULL;
int offset = 0; int offset = 0;
int ooffset = 0; int ooffset = 0;
char *p; char *ptr;
if ((expanded = switch_channel_expand_variables(channel, (char *)vname)) == vname) { if ((expanded = switch_channel_expand_variables(channel, (char *)vname)) == vname) {
expanded = NULL; expanded = NULL;
} else { } else {
vname = expanded; vname = expanded;
} }
if ((p = strchr(vname, ':'))) { if ((ptr = strchr(vname, ':'))) {
*p++ = '\0'; *ptr++ = '\0';
offset = atoi(p); offset = atoi(ptr);
if ((p = strchr(p, ':'))) { if ((ptr = strchr(ptr, ':'))) {
p++; ptr++;
ooffset = atoi(p); ooffset = atoi(ptr);
} }
} }
@ -1528,8 +1530,8 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
} }
if (ooffset > 0 && (size_t)ooffset < strlen(sub_val)) { if (ooffset > 0 && (size_t)ooffset < strlen(sub_val)) {
if ((p = (char *)sub_val + ooffset)) { if ((ptr = (char *)sub_val + ooffset)) {
*p = '\0'; *ptr = '\0';
} }
} }

View File

@ -128,9 +128,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
bytes = (datalen > frame->datalen) ? datalen : frame->datalen; bytes = (datalen > frame->datalen) ? datalen : frame->datalen;
switch_assert( bytes <= maxlen );
if (bytes) { if (bytes) {
int16_t tmp[960], *tp = tmp; int16_t tmp[SWITCH_RECOMMENDED_BUFFER_SIZE], *tp = tmp;
dp = (int16_t *) data; dp = (int16_t *) data;
fp = (int16_t *) frame->data; fp = (int16_t *) frame->data;

View File

@ -277,6 +277,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
*bleg = NULL; *bleg = NULL;
odata = strdup(bridgeto); odata = strdup(bridgeto);
if (!odata) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
status = SWITCH_STATUS_MEMERR;
goto done;
}
data = odata; data = odata;
/* strip leading spaces */ /* strip leading spaces */