From 175d2a81cda1bb4897c700bb0d137deaac9d8612 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Thu, 16 Sep 2021 13:54:02 +0200 Subject: [PATCH] sip: Fix possible NULL pointer dereference The assumption that the IP of the remote peer can always be found in the sdp_connection member of the sdp_session_s struct does not always hold true and we should handle this case gracefully (i.e. without crashing). (cherry picked from commit cf3face6cc2463466e1158d7a020b27ba284a739) --- plugins/sip/calls-sip-origin.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/sip/calls-sip-origin.c b/plugins/sip/calls-sip-origin.c index e628b59..0ebd558 100644 --- a/plugins/sip/calls-sip-origin.c +++ b/plugins/sip/calls-sip-origin.c @@ -521,10 +521,17 @@ sip_i_state (int status, g_autoptr (GList) codecs = calls_sip_media_manager_get_codecs_from_sdp (origin->media_manager, r_sdp->sdp_media); - + const char *remote_ip = NULL; + if (r_sdp->sdp_connection && r_sdp->sdp_connection->c_address) { + remote_ip = r_sdp->sdp_connection->c_address; + } else { + g_warning ("Could not determine IP of remote peer. Hanging up"); + calls_call_hang_up (CALLS_CALL (call)); + return; + } calls_sip_call_set_codecs (call, codecs); calls_sip_call_setup_remote_media_connection (call, - r_sdp->sdp_connection->c_address, + remote_ip, r_sdp->sdp_media->m_port, r_sdp->sdp_media->m_port + 1); }