FS-10118: [freeswitch-core] Race conditions from lack of error checking in switch_core_session_read_lock #resolve

This commit is contained in:
Anthony Minessale
2017-03-09 13:22:11 -06:00
parent abcb7f83a1
commit 35865bd90c
6 changed files with 76 additions and 23 deletions

View File

@@ -3271,14 +3271,22 @@ struct camping_stake {
static void *SWITCH_THREAD_FUNC camp_music_thread(switch_thread_t *thread, void *obj)
{
struct camping_stake *stake = (struct camping_stake *) obj;
switch_core_session_t *session = stake->session;
switch_channel_t *channel = switch_core_session_get_channel(stake->session);
switch_core_session_t *session;
switch_channel_t *channel;
const char *moh = stake->moh, *greet = NULL;
switch_input_args_t args = { 0 };
char dbuf[2] = "";
switch_status_t status = SWITCH_STATUS_FALSE;
const char *stop;
session = stake->session;
if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
return NULL;
}
channel = switch_core_session_get_channel(stake->session);
if ((stop = switch_channel_get_variable(channel, "campon_stop_key"))) {
*dbuf = *stop;
}
@@ -3287,8 +3295,6 @@ static void *SWITCH_THREAD_FUNC camp_music_thread(switch_thread_t *thread, void
args.buf = dbuf;
args.buflen = sizeof(dbuf);
switch_core_session_read_lock(session);
/* don't set this to a local_stream:// or you will not be happy */
if ((greet = switch_channel_get_variable(channel, "campon_announce_sound"))) {
status = switch_ivr_play_file(session, NULL, greet, &args);