Fix crash on transport=tls with non-TLS profile

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.
This commit is contained in:
Travis Cross 2014-10-10 18:25:11 +00:00
parent 1eebeaa7c3
commit 60b36539eb
2 changed files with 8 additions and 4 deletions

View File

@ -7008,7 +7008,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;

View File

@ -2222,7 +2222,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;
@ -3919,9 +3920,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;
}
}