From c977f73e136eca1f2aaccd0ea0fe45c350906374 Mon Sep 17 00:00:00 2001 From: Joshua Colp <jcolp@digium.com> Date: Thu, 3 Oct 2013 14:52:24 +0000 Subject: [PATCH] Fix crashes in res_pjsip_sdp_rtp and res_pjsip_t38 when a stream is rejected and external_media_address is set. The callback function for changing the media address in streams wrongly assumes that a connection line will always be present. This is false as no line is present if a stream has been rejected. (closes issue ASTERISK-22645) Reported by: Rusty Newton ........ Merged revisions 400360 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400361 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_pjsip_sdp_rtp.c | 5 +++++ res/res_pjsip_t38.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c index 4b08621145..57c673e0c6 100644 --- a/res/res_pjsip_sdp_rtp.c +++ b/res/res_pjsip_sdp_rtp.c @@ -1097,6 +1097,11 @@ static void change_outgoing_sdp_stream_media_address(pjsip_tx_data *tdata, struc char host[NI_MAXHOST]; struct ast_sockaddr addr = { { 0, } }; + /* If the stream has been rejected there will be no connection line */ + if (!stream->conn) { + return; + } + ast_copy_pj_str(host, &stream->conn->addr, sizeof(host)); ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID); diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c index 285e9015e6..e44820214c 100644 --- a/res/res_pjsip_t38.c +++ b/res/res_pjsip_t38.c @@ -776,6 +776,11 @@ static void change_outgoing_sdp_stream_media_address(pjsip_tx_data *tdata, struc char host[NI_MAXHOST]; struct ast_sockaddr addr = { { 0, } }; + /* If the stream has been rejected there will be no connection line */ + if (!stream->conn) { + return; + } + ast_copy_pj_str(host, &stream->conn->addr, sizeof(host)); ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID); -- GitLab