From 966b6ddedeb6a36f7cab7a692442647c21155039 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Fri, 2 Jan 2026 10:44:58 -0500 Subject: [PATCH] BUGFIX: fix condition in P25 call handler where if the TSBK was not decoded it could result in a crash; --- src/fne/network/callhandler/TagP25Data.cpp | 48 +++++++++++----------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/fne/network/callhandler/TagP25Data.cpp b/src/fne/network/callhandler/TagP25Data.cpp index 40a7f387..a65f0ffa 100644 --- a/src/fne/network/callhandler/TagP25Data.cpp +++ b/src/fne/network/callhandler/TagP25Data.cpp @@ -184,32 +184,34 @@ bool TagP25Data::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId // special case: if we've received a TSDU and its an LC_CALL_TERM; lets validate the source peer ID, // LC_CALL_TERMs should only be sourced from the peer that initiated the call; other peers should not be // transmitting LC_CALL_TERMs for the call - if (duid == DUID::TSDU && tsbk->getLCO() == LCO::CALL_TERM) { - if (dstId == 0U) { - LogWarning(LOG_NET, "P25, invalid TSDU, peer = %u, ssrc = %u, srcId = %u, dstId = %u, streamId = %u, fromUpstream = %u", peerId, ssrc, srcId, dstId, streamId, fromUpstream); - return false; - } + if (duid == DUID::TSDU && tsbk != nullptr) { + if (tsbk->getLCO() == LCO::CALL_TERM) { + if (dstId == 0U) { + LogWarning(LOG_NET, "P25, invalid TSDU, peer = %u, ssrc = %u, srcId = %u, dstId = %u, streamId = %u, fromUpstream = %u", peerId, ssrc, srcId, dstId, streamId, fromUpstream); + return false; + } - RxStatus status = m_status[dstId]; + RxStatus status = m_status[dstId]; - auto it = std::find_if(m_status.begin(), m_status.end(), [&](StatusMapPair& x) { - if (x.second.dstId == dstId) { - if (x.second.activeCall) - return true; - } - return false; - }); - if (it != m_status.end()) { - if (status.peerId != peerId) { - LogWarning((fromUpstream) ? LOG_PEER : LOG_MASTER, "P25, Illegal Call Termination, peer = %u, ssrc = %u, sysId = $%03X, netId = $%05X, srcId = %u, dstId = %u, streamId = %u, rxPeer = %u, rxSrcId = %u, rxDstId = %u, rxStreamId = %u, fromUpstream = %u", - peerId, ssrc, sysId, netId, srcId, dstId, streamId, status.peerId, status.srcId, status.dstId, status.streamId, fromUpstream); + auto it = std::find_if(m_status.begin(), m_status.end(), [&](StatusMapPair& x) { + if (x.second.dstId == dstId) { + if (x.second.activeCall) + return true; + } return false; - } else { - #define REQ_CALL_END_LOG "P25, Requested Call End, peer = %u, ssrc = %u, sysId = $%03X, netId = $%05X, srcId = %u, dstId = %u, streamId = %u, fromUpstream = %u", peerId, ssrc, sysId, netId, srcId, dstId, streamId, fromUpstream - if (m_network->m_logUpstreamCallStartEnd && fromUpstream) - LogInfoEx(LOG_PEER, REQ_CALL_END_LOG); - else if (!fromUpstream) - LogInfoEx(LOG_MASTER, REQ_CALL_END_LOG); + }); + if (it != m_status.end()) { + if (status.peerId != peerId) { + LogWarning((fromUpstream) ? LOG_PEER : LOG_MASTER, "P25, Illegal Call Termination, peer = %u, ssrc = %u, sysId = $%03X, netId = $%05X, srcId = %u, dstId = %u, streamId = %u, rxPeer = %u, rxSrcId = %u, rxDstId = %u, rxStreamId = %u, fromUpstream = %u", + peerId, ssrc, sysId, netId, srcId, dstId, streamId, status.peerId, status.srcId, status.dstId, status.streamId, fromUpstream); + return false; + } else { + #define REQ_CALL_END_LOG "P25, Requested Call End, peer = %u, ssrc = %u, sysId = $%03X, netId = $%05X, srcId = %u, dstId = %u, streamId = %u, fromUpstream = %u", peerId, ssrc, sysId, netId, srcId, dstId, streamId, fromUpstream + if (m_network->m_logUpstreamCallStartEnd && fromUpstream) + LogInfoEx(LOG_PEER, REQ_CALL_END_LOG); + else if (!fromUpstream) + LogInfoEx(LOG_MASTER, REQ_CALL_END_LOG); + } } } }