Fixed unsafe check for the client ID being kicked

fixed Super Team collision with doors

Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
GreYFoXGTi 2010-09-29 23:24:28 +03:00
parent 33c8265110
commit 65830a463d
2 changed files with 12 additions and 9 deletions

View file

@ -1438,9 +1438,14 @@ int CServer::Run()
void CServer::ConKick(IConsole::IResult *pResult, void *pUser, int ClientId)
{
int ClientId1 = pResult->GetInteger(0);
if (ClientId == -1 || ((CServer *)pUser)->m_aClients[ClientId].m_Authed > ((CServer *)pUser)->m_aClients[ClientId1].m_Authed)
char buf[128];
if(ClientId1 < 0 || ClientId1 >= MAX_CLIENTS || m_aClients[ClientId1].m_State == CClient::STATE_EMPTY)
{
str_format(buf, sizeof(buf),"Invalid Client ID %d", ClientId1);
((CServer *)pUser)->SendRconLine(ClientId,buf);
}
else if (ClientId == -1 || ((CServer *)pUser)->m_aClients[ClientId].m_Authed > ((CServer *)pUser)->m_aClients[ClientId1].m_Authed)
{
char buf[128];
str_format(buf, sizeof(buf),"Kicked by %s", ((CServer *)pUser)->ClientName(ClientId));
((CServer *)pUser)->Kick(ClientId1, buf);
}

View file

@ -241,14 +241,14 @@ void CCollision::SetCollisionAt(float x, float y, int flag)
void CCollision::SetDTile(float x, float y, int Team, bool State)
{
if(!m_pDoor || ((Team < 0 || Team > MAX_CLIENTS) && Team !=99))
if(!m_pDoor || ((Team < 0 || Team > (MAX_CLIENTS - 1)) && Team !=99))
return;
int nx = clamp(round(x)/32, 0, m_Width-1);
int ny = clamp(round(y)/32, 0, m_Height-1);
if(Team == 99)
{
for (int i = 0; i < MAX_CLIENTS; ++i)
for (int i = 0; i < (MAX_CLIENTS - 1); ++i)
{
m_pDoor[ny * m_Width + nx].m_Team[i] = State;
}
@ -259,7 +259,7 @@ void CCollision::SetDTile(float x, float y, int Team, bool State)
void CCollision::SetDCollisionAt(float x, float y, int Flag, int Team)
{
if(!m_pDoor || ((Team < 0 || Team > MAX_CLIENTS) && Team !=99))
if(!m_pDoor || ((Team < 0 || Team > (MAX_CLIENTS - 1)) && Team !=99))
return;
int nx = clamp(round(x)/32, 0, m_Width-1);
int ny = clamp(round(y)/32, 0, m_Height-1);
@ -267,7 +267,7 @@ void CCollision::SetDCollisionAt(float x, float y, int Flag, int Team)
m_pDoor[ny * m_Width + nx].m_Index = Flag;
if(Team == 99)
{
for (int i = 0; i < MAX_CLIENTS; ++i)
for (int i = 0; i < (MAX_CLIENTS - 1); ++i)
{
m_pDoor[ny * m_Width + nx].m_Team[i] = true;
}
@ -278,10 +278,8 @@ void CCollision::SetDCollisionAt(float x, float y, int Flag, int Team)
int CCollision::GetDTileIndex(int Index,int Team)
{
if(!m_pDoor || !m_pDoor[Index].m_Index || ((Team < 0 || Team > MAX_CLIENTS) && Team !=99))
{
if(!m_pDoor || !m_pDoor[Index].m_Index || ((Team < 0 || Team > (MAX_CLIENTS - 1)) && Team !=99))
return 0;
}
if(m_pDoor[Index].m_Team[Team])
return m_pDoor[Index].m_Index;