mirror of
https://github.com/ShaYmez/xlxd.git
synced 2024-12-23 01:55:49 -05:00
xlxd version 1.4.3
Protection against sid=0
This commit is contained in:
parent
76dc7d1ecf
commit
55b75a7c6f
@ -173,52 +173,61 @@ CPacketStream *CReflector::OpenStream(CDvHeaderPacket *DvHeader, CClient *client
|
|||||||
// clients MUST have bee locked by the caller
|
// clients MUST have bee locked by the caller
|
||||||
// so we can freely access it within the fuction
|
// so we can freely access it within the fuction
|
||||||
|
|
||||||
// check if client is valid candidate
|
// check if streamid is valid
|
||||||
if ( m_Clients.IsClient(client) && !client->IsAMaster() )
|
if ( DvHeader->GetStreamId() != 0 )
|
||||||
{
|
{
|
||||||
// check if no stream with same streamid already open
|
// check if client is valid candidate
|
||||||
// to prevent loops
|
if ( m_Clients.IsClient(client) && !client->IsAMaster() )
|
||||||
if ( !IsStreamOpen(DvHeader) )
|
|
||||||
{
|
{
|
||||||
// get the module's queue
|
// check if no stream with same streamid already open
|
||||||
char module = DvHeader->GetRpt2Module();
|
// to prevent loops
|
||||||
CPacketStream *stream = GetStream(module);
|
if ( !IsStreamOpen(DvHeader) )
|
||||||
if ( stream != NULL )
|
|
||||||
{
|
{
|
||||||
// lock it
|
// get the module's queue
|
||||||
stream->Lock();
|
char module = DvHeader->GetRpt2Module();
|
||||||
// is it available ?
|
CPacketStream *stream = GetStream(module);
|
||||||
if ( stream->Open(*DvHeader, client) )
|
if ( stream != NULL )
|
||||||
{
|
{
|
||||||
// stream open, mark client as master
|
// lock it
|
||||||
// so that it can't be deleted
|
stream->Lock();
|
||||||
client->SetMasterOfModule(module);
|
// is it available ?
|
||||||
|
if ( stream->Open(*DvHeader, client) )
|
||||||
|
{
|
||||||
|
// stream open, mark client as master
|
||||||
|
// so that it can't be deleted
|
||||||
|
client->SetMasterOfModule(module);
|
||||||
|
|
||||||
// update last heard time
|
// update last heard time
|
||||||
client->Heard();
|
client->Heard();
|
||||||
retStream = stream;
|
retStream = stream;
|
||||||
|
|
||||||
// and push header packet
|
// and push header packet
|
||||||
stream->Push(DvHeader);
|
stream->Push(DvHeader);
|
||||||
|
|
||||||
// report
|
// report
|
||||||
std::cout << "Opening stream on module " << module << " for client " << client->GetCallsign()
|
std::cout << "Opening stream on module " << module << " for client " << client->GetCallsign()
|
||||||
<< " with sid " << DvHeader->GetStreamId() << std::endl;
|
<< " with sid " << DvHeader->GetStreamId() << std::endl;
|
||||||
|
|
||||||
// notify
|
// notify
|
||||||
g_Reflector.OnStreamOpen(stream->GetUserCallsign());
|
g_Reflector.OnStreamOpen(stream->GetUserCallsign());
|
||||||
|
|
||||||
|
}
|
||||||
|
// unlock now
|
||||||
|
stream->Unlock();
|
||||||
}
|
}
|
||||||
// unlock now
|
}
|
||||||
stream->Unlock();
|
else
|
||||||
|
{
|
||||||
|
// report
|
||||||
|
std::cout << "Detected stream loop on module " << DvHeader->GetRpt2Module() << " for client " << client->GetCallsign()
|
||||||
|
<< " with sid " << DvHeader->GetStreamId() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
// report
|
{
|
||||||
std::cout << "Detected stream loop on module " << DvHeader->GetRpt2Module() << " for client " << client->GetCallsign()
|
// report
|
||||||
<< " with sid " << DvHeader->GetStreamId() << std::endl;
|
std::cout << "Detected null stream id for client " << client->GetCallsign() << std::endl;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// done
|
// done
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 4
|
#define VERSION_MINOR 4
|
||||||
#define VERSION_REVISION 2
|
#define VERSION_REVISION 3
|
||||||
|
|
||||||
// global ------------------------------------------------------
|
// global ------------------------------------------------------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user