mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-02-22 17:42:39 +00:00
FS-4408 fix crash caused by missing or invalid call-id in sip invite
This commit is contained in:
parent
956b8a3d45
commit
5a234a6099
@ -1690,6 +1690,14 @@ static void sofia_queue_message(sofia_dispatch_event_t *de)
|
|||||||
switch_queue_push(mod_sofia_globals.msg_queue, de);
|
switch_queue_push(mod_sofia_globals.msg_queue, de);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_call_id(private_object_t *tech_pvt, sip_t const *sip)
|
||||||
|
{
|
||||||
|
if (!tech_pvt->call_id && tech_pvt->session && tech_pvt->channel && sip && sip->sip_call_id && sip->sip_call_id->i_id) {
|
||||||
|
tech_pvt->call_id = switch_core_session_strdup(tech_pvt->session, sip->sip_call_id->i_id);
|
||||||
|
switch_channel_set_variable(tech_pvt->channel, "sip_call_id", tech_pvt->call_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void sofia_event_callback(nua_event_t event,
|
void sofia_event_callback(nua_event_t event,
|
||||||
int status,
|
int status,
|
||||||
@ -1709,16 +1717,22 @@ void sofia_event_callback(nua_event_t event,
|
|||||||
|
|
||||||
if ((session = switch_core_session_locate(sofia_private->uuid))) {
|
if ((session = switch_core_session_locate(sofia_private->uuid))) {
|
||||||
private_object_t *tech_pvt = switch_core_session_get_private(session);
|
private_object_t *tech_pvt = switch_core_session_get_private(session);
|
||||||
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "detaching session %s\n", sofia_private->uuid);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "detaching session %s\n", sofia_private->uuid);
|
||||||
|
set_call_id(tech_pvt, sip);
|
||||||
|
|
||||||
tech_pvt->sofia_private = NULL;
|
if (!zstr(tech_pvt->call_id)) {
|
||||||
tech_pvt->nh = NULL;
|
tech_pvt->sofia_private = NULL;
|
||||||
sofia_set_flag(tech_pvt, TFLAG_BYE);
|
tech_pvt->nh = NULL;
|
||||||
switch_mutex_lock(profile->flag_mutex);
|
sofia_set_flag(tech_pvt, TFLAG_BYE);
|
||||||
switch_core_hash_insert(profile->chat_hash, tech_pvt->call_id, strdup(switch_core_session_get_uuid(session)));
|
switch_mutex_lock(profile->flag_mutex);
|
||||||
switch_mutex_unlock(profile->flag_mutex);
|
switch_core_hash_insert(profile->chat_hash, tech_pvt->call_id, strdup(switch_core_session_get_uuid(session)));
|
||||||
switch_core_session_rwunlock(session);
|
switch_mutex_unlock(profile->flag_mutex);
|
||||||
|
switch_core_session_rwunlock(session);
|
||||||
|
} else {
|
||||||
|
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goto end;
|
goto end;
|
||||||
@ -1804,10 +1818,26 @@ void sofia_event_callback(nua_event_t event,
|
|||||||
} else {
|
} else {
|
||||||
free(uuid);
|
free(uuid);
|
||||||
uuid = NULL;
|
uuid = NULL;
|
||||||
|
sip = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!sip || !sip->sip_call_id || zstr(sip->sip_call_id->i_id)) {
|
||||||
|
nua_respond(nh, 503, "INVALID INVITE", TAG_END());
|
||||||
|
nua_destroy_event(de->event);
|
||||||
|
su_free(nh->nh_home, de);
|
||||||
|
|
||||||
|
switch_mutex_lock(profile->flag_mutex);
|
||||||
|
profile->queued_events--;
|
||||||
|
switch_mutex_unlock(profile->flag_mutex);
|
||||||
|
|
||||||
|
nua_handle_unref(nh);
|
||||||
|
nua_stack_unref(nua);
|
||||||
|
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
if (sofia_test_pflag(profile, PFLAG_CALLID_AS_UUID)) {
|
if (sofia_test_pflag(profile, PFLAG_CALLID_AS_UUID)) {
|
||||||
session = switch_core_session_request_uuid(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL, sip->sip_call_id->i_id);
|
session = switch_core_session_request_uuid(sofia_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL, sip->sip_call_id->i_id);
|
||||||
} else {
|
} else {
|
||||||
@ -1830,12 +1860,7 @@ void sofia_event_callback(nua_event_t event,
|
|||||||
|
|
||||||
sofia_glue_attach_private(session, profile, tech_pvt, channel_name);
|
sofia_glue_attach_private(session, profile, tech_pvt, channel_name);
|
||||||
|
|
||||||
if (!tech_pvt->call_id && sip->sip_call_id && sip->sip_call_id->i_id) {
|
set_call_id(tech_pvt, sip);
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
|
||||||
tech_pvt->call_id = switch_core_session_strdup(session, sip->sip_call_id->i_id);
|
|
||||||
switch_channel_set_variable(channel, "sip_call_id", tech_pvt->call_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
|
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
|
||||||
nua_destroy_event(de->event);
|
nua_destroy_event(de->event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user