[calls/gnome-41] sip: Fix possible NULL pointer dereference



commit 175d2a81cda1bb4897c700bb0d137deaac9d8612
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Thu Sep 16 13:54:02 2021 +0200

    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 e628b593..0ebd5585 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);
   }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]