BUGFIX: fix condition in P25 call handler where if the TSBK was not decoded it could result in a crash;

r05a04_dev
Bryan Biedenkapp 1 month ago
parent e5d8eed40c
commit 966b6ddede

@ -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, // 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 // 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 // transmitting LC_CALL_TERMs for the call
if (duid == DUID::TSDU && tsbk->getLCO() == LCO::CALL_TERM) { if (duid == DUID::TSDU && tsbk != nullptr) {
if (dstId == 0U) { if (tsbk->getLCO() == LCO::CALL_TERM) {
LogWarning(LOG_NET, "P25, invalid TSDU, peer = %u, ssrc = %u, srcId = %u, dstId = %u, streamId = %u, fromUpstream = %u", peerId, ssrc, srcId, dstId, streamId, fromUpstream); if (dstId == 0U) {
return false; 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) { auto it = std::find_if(m_status.begin(), m_status.end(), [&](StatusMapPair& x) {
if (x.second.dstId == dstId) { if (x.second.dstId == dstId) {
if (x.second.activeCall) if (x.second.activeCall)
return true; 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);
return false; 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 (it != m_status.end()) {
if (m_network->m_logUpstreamCallStartEnd && fromUpstream) if (status.peerId != peerId) {
LogInfoEx(LOG_PEER, REQ_CALL_END_LOG); 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",
else if (!fromUpstream) peerId, ssrc, sysId, netId, srcId, dstId, streamId, status.peerId, status.srcId, status.dstId, status.streamId, fromUpstream);
LogInfoEx(LOG_MASTER, REQ_CALL_END_LOG); 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);
}
} }
} }
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.