<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14493">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_fax: Don't start a gateway if either channel is hung up<br><br>When fax_gateway_framehook is called and a gateway hasn't already<br>been started, the framehook gets the t38 state for both the current<br>channel and the peer. That call trickles down to the channel<br>driver which determines the state. If either channel is hung up<br>(or in the process of being hung up), the channel driver's tech_pvt<br>is going to be NULL which, in the case of chan_pjsip, will cause a<br>segfault.<br><br>* Added a hangup check for both the channel and peer channel<br> before starting a fax gateway.<br><br>* Added a check for NULL tech_pvt to chan_pjsip_queryoption<br> so we don't attempt to reference a tech_pvt that's already<br> gone.<br><br>ASTERISK-28923<br>Reported by: Yury Kirsanov<br><br>Change-Id: I4e10e63b667bbb68c1c8623f977488f5d807897c<br>---<br>M channels/chan_pjsip.c<br>M res/res_fax.c<br>2 files changed, 15 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c</span><br><span>index c8b6fe7..692151a 100644</span><br><span>--- a/channels/chan_pjsip.c</span><br><span>+++ b/channels/chan_pjsip.c</span><br><span>@@ -1238,14 +1238,17 @@</span><br><span> static int chan_pjsip_queryoption(struct ast_channel *ast, int option, void *data, int *datalen)</span><br><span> {</span><br><span> struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(ast);</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_sip_session *session = channel->session;</span><br><span> int res = -1;</span><br><span> enum ast_t38_state state = T38_STATE_UNAVAILABLE;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (!channel) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> switch (option) {</span><br><span> case AST_OPTION_T38_STATE:</span><br><span style="color: hsl(0, 100%, 40%);">- if (session->endpoint->media.t38.enabled) {</span><br><span style="color: hsl(0, 100%, 40%);">- switch (session->t38state) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (channel->session->endpoint->media.t38.enabled) {</span><br><span style="color: hsl(120, 100%, 40%);">+ switch (channel->session->t38state) {</span><br><span> case T38_LOCAL_REINVITE:</span><br><span> case T38_PEER_REINVITE:</span><br><span> state = T38_STATE_NEGOTIATING;</span><br><span>diff --git a/res/res_fax.c b/res/res_fax.c</span><br><span>index b895c57..190ba1b 100644</span><br><span>--- a/res/res_fax.c</span><br><span>+++ b/res/res_fax.c</span><br><span>@@ -3442,6 +3442,15 @@</span><br><span> if (!gateway->bridged) {</span><br><span> enum ast_t38_state state_chan;</span><br><span> enum ast_t38_state state_peer;</span><br><span style="color: hsl(120, 100%, 40%);">+ int chan_is_hungup;</span><br><span style="color: hsl(120, 100%, 40%);">+ int peer_is_hungup;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ chan_is_hungup = ast_check_hangup(chan);</span><br><span style="color: hsl(120, 100%, 40%);">+ peer_is_hungup = ast_check_hangup(peer);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Don't start a gateway if either channel is hung up */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (chan_is_hungup || peer_is_hungup) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return f;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span> ast_channel_unlock(chan);</span><br><span> state_chan = ast_channel_get_t38_state(chan);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14493">change 14493</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/+/14493"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I4e10e63b667bbb68c1c8623f977488f5d807897c </div>
<div style="display:none"> Gerrit-Change-Number: 14493 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>