From 3c4fdca9e0bb43f9656fa70f00e4ddf738a2169b Mon Sep 17 00:00:00 2001 From: Moises Silva Date: Wed, 7 Mar 2012 19:04:31 -0500 Subject: [PATCH] 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 --- libs/freetdm/src/ftdm_io.c | 6 ++++++ .../src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 3b11611d49..513fc0c595 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -2449,6 +2449,12 @@ FT_DECLARE(ftdm_status_t) ftdm_get_channel_from_string(const char *string_id, ft *out_span = 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); if (rc != 2) { ftdm_log(FTDM_LOG_ERROR, "Failed to parse channel id string '%s'\n", string_id); diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c index 84b9a9b7f2..5f0a0f0960 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_out.c @@ -57,12 +57,12 @@ void ft_to_sngss7_iam (ftdm_channel_t * ftdmchan) memset (&iam, 0x0, sizeof (iam)); - var = ftdm_usrmsg_get_var(ftdmchan->usrmsg, "sigbridge_peer"); - if (!ftdm_strlen_zero(var)) { + if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_NATIVE_SIGBRIDGE)) { ftdm_span_t *peer_span = NULL; ftdm_channel_t *peer_chan = 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); if (!peer_chan) { 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_event_data_t *event_clone = ftdm_queue_dequeue(sngss7_info->peer_data->event_queue); /* Retrieve IAM from our peer */