From 773216d5172697e00d423cdb5513f28f30059c2a 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 3d535a13..da9c0a72 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); } @@ -1506,8 +1511,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); }