mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #4389
4389: Sanitize owner data in client (fixes #4388) r=edg-l a=def- and don't access out of scope on owner < 0 <!-- What is the motivation for the changes of this pull request --> ## Checklist - [x] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [x] Considered possible null pointers and out of bounds array indexing - [x] Changed no physics that affect existing maps - [x] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
c74b0c8536
|
@ -327,7 +327,7 @@ void CItems::OnRender()
|
|||
}
|
||||
for(auto *pLaser = (CLaser *)GameClient()->m_PredictedWorld.FindFirst(CGameWorld::ENTTYPE_LASER); pLaser; pLaser = (CLaser *)pLaser->NextEntity())
|
||||
{
|
||||
if(pLaser->GetOwner() < 0 || (pLaser->GetOwner() >= 0 && !GameClient()->m_aClients[pLaser->GetOwner()].m_IsPredictedLocal))
|
||||
if(pLaser->GetOwner() < 0 || !GameClient()->m_aClients[pLaser->GetOwner()].m_IsPredictedLocal)
|
||||
continue;
|
||||
CNetObj_Laser Data;
|
||||
pLaser->FillInfo(&Data);
|
||||
|
@ -376,17 +376,20 @@ void CItems::OnRender()
|
|||
{
|
||||
if(auto *pProj = (CProjectile *)GameClient()->m_GameWorld.FindMatch(Item.m_ID, Item.m_Type, pData))
|
||||
{
|
||||
bool IsOtherTeam = m_pClient->IsOtherTeam(pProj->GetOwner());
|
||||
if(pProj->m_LastRenderTick <= 0 && (pProj->m_Type != WEAPON_SHOTGUN || (!pProj->m_Freeze && !pProj->m_Explosive)) // skip ddrace shotgun bullets
|
||||
&& (pProj->m_Type == WEAPON_SHOTGUN || fabs(length(pProj->m_Direction) - 1.f) < 0.02) // workaround to skip grenades on ball mod
|
||||
&& (pProj->GetOwner() < 0 || !GameClient()->m_aClients[pProj->GetOwner()].m_IsPredictedLocal || IsOtherTeam) // skip locally predicted projectiles
|
||||
&& !Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_ID))
|
||||
if(pProj->GetOwner() >= 0)
|
||||
{
|
||||
ReconstructSmokeTrail(&Data, pProj->m_DestroyTick);
|
||||
bool IsOtherTeam = m_pClient->IsOtherTeam(pProj->GetOwner());
|
||||
if(pProj->m_LastRenderTick <= 0 && (pProj->m_Type != WEAPON_SHOTGUN || (!pProj->m_Freeze && !pProj->m_Explosive)) // skip ddrace shotgun bullets
|
||||
&& (pProj->m_Type == WEAPON_SHOTGUN || fabs(length(pProj->m_Direction) - 1.f) < 0.02) // workaround to skip grenades on ball mod
|
||||
&& (pProj->GetOwner() < 0 || !GameClient()->m_aClients[pProj->GetOwner()].m_IsPredictedLocal || IsOtherTeam) // skip locally predicted projectiles
|
||||
&& !Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_ID))
|
||||
{
|
||||
ReconstructSmokeTrail(&Data, pProj->m_DestroyTick);
|
||||
}
|
||||
pProj->m_LastRenderTick = Client()->GameTick(g_Config.m_ClDummy);
|
||||
if(!IsOtherTeam)
|
||||
continue;
|
||||
}
|
||||
pProj->m_LastRenderTick = Client()->GameTick(g_Config.m_ClDummy);
|
||||
if(!IsOtherTeam)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(Inactive && (Data.m_Explosive ? BlinkingProjEx : BlinkingProj))
|
||||
|
|
|
@ -49,7 +49,7 @@ CProjectileData ExtractProjectileInfoDDNet(const CNetObj_DDNetProjectile *pProj,
|
|||
|
||||
Result.m_ExtraInfo = true;
|
||||
Result.m_Owner = pProj->m_Data & 255;
|
||||
if(pProj->m_Data & PROJECTILEFLAG_NO_OWNER)
|
||||
if(pProj->m_Data & PROJECTILEFLAG_NO_OWNER || Result.m_Owner < 0 || Result.m_Owner >= MAX_CLIENTS)
|
||||
{
|
||||
Result.m_Owner = -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue