<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15484">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  George Joseph: Looks good to me, approved; Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">AST-2021-002: Remote crash possible when negotiating T.38<br><br>When an endpoint requests to re-negotiate for fax and the incoming<br>re-invite is received prior to Asterisk sending out the 200 OK for<br>the initial invite the re-invite gets delayed. When Asterisk does<br>finally send the re-inivite the SDP includes streams for both audio<br>and T.38.<br><br>This happens because when the pending topology and active topologies<br>differ (pending stream is not in the active) in the delayed scenario<br>the pending stream is appended to the active topology. However, in<br>the fax case the pending stream should replace the active.<br><br>This patch makes it so when a delay occurs during fax negotiation,<br>to or from, the audio stream is replaced by the T.38 stream, or vice<br>versa instead of being appended.<br><br>Further when Asterisk sent the re-invite with both audio and T.38,<br>and the endpoint responded with a declined T.38 stream then Asterisk<br>would crash when attempting to change the T.38 state.<br><br>This patch also puts in a check that ensures the media state has a<br>valid fax session (associated udptl object) before changing the<br>T.38 state internally.<br><br>ASTERISK-29203 #close<br><br>Change-Id: I407f4fa58651255b6a9030d34fd6578cf65ccf09<br>---<br>M res/res_pjsip_session.c<br>M res/res_pjsip_t38.c<br>2 files changed, 17 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c</span><br><span>index dfbc9a6..c5bd2bf 100644</span><br><span>--- a/res/res_pjsip_session.c</span><br><span>+++ b/res/res_pjsip_session.c</span><br><span>@@ -2267,7 +2267,14 @@</span><br><span>                                    ast_sip_session_get_name(session));</span><br><span>                  }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-                   if (active_media_state) {</span><br><span style="color: hsl(120, 100%, 40%);">+                     /*</span><br><span style="color: hsl(120, 100%, 40%);">+                     * Attempt to resolve only if objects are available, and it's not</span><br><span style="color: hsl(120, 100%, 40%);">+                  * switching to or from an image type.</span><br><span style="color: hsl(120, 100%, 40%);">+                         */</span><br><span style="color: hsl(120, 100%, 40%);">+                   if (active_media_state && active_media_state->topology &&</span><br><span style="color: hsl(120, 100%, 40%);">+                          (!active_media_state->default_session[AST_MEDIA_TYPE_IMAGE] ==</span><br><span style="color: hsl(120, 100%, 40%);">+                              !pending_media_state->default_session[AST_MEDIA_TYPE_IMAGE])) {</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>                                struct ast_sip_session_media_state *new_pending_state;</span><br><span>                               /*</span><br><span>                            * We need to check if the passed in active and pending states are equal</span><br><span>diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c</span><br><span>index 9c9569b..63abce5 100644</span><br><span>--- a/res/res_pjsip_t38.c</span><br><span>+++ b/res/res_pjsip_t38.c</span><br><span>@@ -320,6 +320,15 @@</span><br><span>             int index;</span><br><span> </span><br><span>               session_media = session->active_media_state->default_session[AST_MEDIA_TYPE_IMAGE];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+           /*</span><br><span style="color: hsl(120, 100%, 40%);">+             * If there is a session_media object, but no udptl object available</span><br><span style="color: hsl(120, 100%, 40%);">+           * then it's assumed the stream was declined.</span><br><span style="color: hsl(120, 100%, 40%);">+              */</span><br><span style="color: hsl(120, 100%, 40%);">+           if (!session_media->udptl) {</span><br><span style="color: hsl(120, 100%, 40%);">+                       session_media = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>          if (!session_media) {</span><br><span>                        ast_log(LOG_WARNING, "Received %d response to T.38 re-invite on '%s' but no active session media\n",</span><br><span>                                       status.code, session->channel ? ast_channel_name(session->channel) : "unknown channel");</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15484">change 15484</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/15484"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: certified/16.8 </div>
<div style="display:none"> Gerrit-Change-Id: I407f4fa58651255b6a9030d34fd6578cf65ccf09 </div>
<div style="display:none"> Gerrit-Change-Number: 15484 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-CC: Friendly Automation </div>
<div style="display:none"> Gerrit-MessageType: merged </div>