freetdm: Fix redmine issue #2931 - Crash on SIP to SS7 call after sigbridge call

The code was improperly using peer_data as an indicator that the sigbridge
         ss7 mode was enabled. The channel flag FTDM_CHANNEL_NATIVE_SIGBRDIGE should
         be used instead
This commit is contained in:
Moises Silva 2012-03-07 19:04:31 -05:00 committed by James Zhang
parent eeec65265a
commit 3c4fdca9e0
2 changed files with 9 additions and 3 deletions

View File

@ -2449,6 +2449,12 @@ FT_DECLARE(ftdm_status_t) ftdm_get_channel_from_string(const char *string_id, ft
*out_span = NULL; *out_span = NULL;
*out_channel = NULL; *out_channel = NULL;
if (!string_id) {
ftdm_log(FTDM_LOG_ERROR, "Cannot parse NULL channel id string\n");
status = FTDM_EINVAL;
goto done;
}
rc = sscanf(string_id, "%u:%u", &span_id, &chan_id); rc = sscanf(string_id, "%u:%u", &span_id, &chan_id);
if (rc != 2) { if (rc != 2) {
ftdm_log(FTDM_LOG_ERROR, "Failed to parse channel id string '%s'\n", string_id); ftdm_log(FTDM_LOG_ERROR, "Failed to parse channel id string '%s'\n", string_id);

View File

@ -57,12 +57,12 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
memset (&iam, 0x0, sizeof (iam)); memset (&iam, 0x0, sizeof (iam));
var = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "sigbridge_peer"); if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE)) {
if (!ftdm_strlen_zero(var)) {
ftdm_span_t *peer_span = NULL; ftdm_span_t *peer_span = NULL;
ftdm_channel_t *peer_chan = NULL; ftdm_channel_t *peer_chan = NULL;
sngss7_chan_data_t *peer_info = NULL; sngss7_chan_data_t *peer_info = NULL;
var = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "sigbridge_peer");
ftdm_get_channel_from_string(var, &peer_span, &peer_chan); ftdm_get_channel_from_string(var, &peer_span, &peer_chan);
if (!peer_chan) { if (!peer_chan) {
SS7_ERROR_CHAN(ftdmchan, "Failed to find sigbridge peer from string '%s'\n", var); SS7_ERROR_CHAN(ftdmchan, "Failed to find sigbridge peer from string '%s'\n", var);
@ -91,7 +91,7 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan)
} }
} }
if (sngss7_info->peer_data) { if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE) && sngss7_info->peer_data) {
sngss7_span_data_t *span_data = ftdmchan->span->signal_data; sngss7_span_data_t *span_data = ftdmchan->span->signal_data;
sngss7_event_data_t *event_clone = ftdm_queue_dequeue(sngss7_info->peer_data->event_queue); sngss7_event_data_t *event_clone = ftdm_queue_dequeue(sngss7_info->peer_data->event_queue);
/* Retrieve IAM from our peer */ /* Retrieve IAM from our peer */