]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Fix crash on transport=tls with non-TLS profile
authorTravis Cross <tc@traviscross.com>
Fri, 10 Oct 2014 18:25:11 +0000 (18:25 +0000)
committerTravis Cross <tc@traviscross.com>
Fri, 10 Oct 2014 18:36:37 +0000 (18:36 +0000)
We use the transport of the Contact header of the remote UAC to decide
which of our own Contact addresses we should use when replying to a
SUBSCRIBE or sending a presence NOTIFY.

If TLS is not enabled on a Sofia profile, then the TLS Contacts for
that profile are NULL.  Unfortunately we were using these NULL values
uncritically when the remote UAC sent us a Contact header with a TLS
transport and our own Sofia profile did not have TLS enabled.

With this commit we fall back to our TCP Contact address when the
remote Contact is TLS and our Sofia profile does not have TLS enabled.

src/mod/endpoints/mod_sofia/sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_presence.c

index a52ba0473dcc641e2fa40e2549cfa92f45ffad56..0773e45b5091500008e30a55a2dc24b59c2d4685 100644 (file)
@@ -2667,7 +2667,8 @@ switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *use
                                contact_str = profile->tcp_public_contact;
                                break;
                        case SOFIA_TRANSPORT_TCP_TLS:
-                               contact_str = profile->tls_public_contact;
+                               contact_str = sofia_test_pflag(profile, PFLAG_TLS) ?
+                                       profile->tls_public_contact : profile->tcp_public_contact;
                                break;
                        default:
                                contact_str = profile->public_url;
@@ -2690,7 +2691,8 @@ switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *use
                                contact_str = profile->tcp_contact;
                                break;
                        case SOFIA_TRANSPORT_TCP_TLS:
-                               contact_str = profile->tls_contact;
+                               contact_str = sofia_test_pflag(profile, PFLAG_TLS) ?
+                                       profile->tls_contact : profile->tcp_contact;
                                break;
                        default:
                                contact_str = profile->url;
index a7e4e6f78f162060c946b2cd4adf8d5a4838a6c6..d8cb06866d0b7ea08a733f7f49fbce479b82458d 100644 (file)
@@ -2227,7 +2227,8 @@ static void _send_presence_notify(sofia_profile_t *profile,
                        contact_str = profile->tcp_public_contact;
                        break;
                case SOFIA_TRANSPORT_TCP_TLS:
-                       contact_str = profile->tls_public_contact;
+                       contact_str = sofia_test_pflag(profile, PFLAG_TLS) ?
+                               profile->tls_public_contact : profile->tcp_public_contact;
                        break;
                default:
                        contact_str = profile->public_url;
@@ -2241,7 +2242,8 @@ static void _send_presence_notify(sofia_profile_t *profile,
                        contact_str = profile->tcp_contact;
                        break;
                case SOFIA_TRANSPORT_TCP_TLS:
-                       contact_str = profile->tls_contact;
+                       contact_str = sofia_test_pflag(profile, PFLAG_TLS) ?
+                               profile->tls_contact : profile->tcp_contact;
                        break;
                default:
                        contact_str = profile->url;
@@ -2687,7 +2689,8 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
                                contact_str = profile->tcp_public_contact;
                                break;
                        case SOFIA_TRANSPORT_TCP_TLS:
-                               contact_str = profile->tls_public_contact;
+                               contact_str = sofia_test_pflag(profile, PFLAG_TLS) ?
+                                       profile->tls_public_contact : profile->tcp_public_contact;
                                break;
                        default:
                                contact_str = profile->public_url;
@@ -2706,7 +2709,8 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
                                contact_str = profile->tcp_contact;
                                break;
                        case SOFIA_TRANSPORT_TCP_TLS:
-                               contact_str = profile->tls_contact;
+                               contact_str = sofia_test_pflag(profile, PFLAG_TLS) ?
+                                       profile->tls_contact : profile->tcp_contact;
                                break;
                        default:
                                contact_str = profile->url;
@@ -4036,9 +4040,11 @@ void sofia_presence_handle_sip_i_subscribe(int status,
                        }
                } else if (switch_stristr("port=tls", contact->m_url->url_params)) {
                        if (np.is_auto_nat) {
-                               cs = profile->tls_public_contact;
+                               cs = sofia_test_pflag(profile, PFLAG_TLS) ?
+                                       profile->tls_public_contact : profile->tcp_public_contact;
                        } else {
-                               cs = profile->tls_contact;
+                               cs = sofia_test_pflag(profile, PFLAG_TLS) ?
+                                       profile->tls_contact : profile->tcp_contact;
                        }
                }