From ab06cf478831586ba4b88acf9a0f9345134aa8ab Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 16 Dec 2012 19:52:31 -0500 Subject: [PATCH] Validate entity in GetEntPropEnt, GetEntDataEnt2 (r=me). --- core/smn_entities.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/smn_entities.cpp b/core/smn_entities.cpp index 49ea4632..fd6eafda 100644 --- a/core/smn_entities.cpp +++ b/core/smn_entities.cpp @@ -620,8 +620,13 @@ static cell_t GetEntDataEnt2(IPluginContext *pContext, const cell_t *params) } CBaseHandle &hndl = *(CBaseHandle *)((uint8_t *)pEntity + offset); + int index = hndl.GetEntryIndex(); - int ref = g_HL2.IndexToReference(hndl.GetEntryIndex()); + CEntInfo *pInfo = g_HL2.LookupEntity(index); + if (pInfo->m_SerialNumber != hndl.GetSerialNumber()) + return -1; + + int ref = g_HL2.IndexToReference(index); return g_HL2.ReferenceToBCompatRef(ref); } @@ -1493,8 +1498,13 @@ static cell_t GetEntPropEnt(IPluginContext *pContext, const cell_t *params) } CBaseHandle &hndl = *(CBaseHandle *)((uint8_t *)pEntity + offset); + int index = hndl.GetEntryIndex(); - int ref = g_HL2.IndexToReference(hndl.GetEntryIndex()); + CEntInfo *pInfo = g_HL2.LookupEntity(index); + if (pInfo->m_SerialNumber != hndl.GetSerialNumber()) + return -1; + + int ref = g_HL2.IndexToReference(index); return g_HL2.ReferenceToBCompatRef(ref); }