Validate entity in GameRules_GetPropEnt and in CS_DropWeapon safety checks.
Validate entity in GameRules_GetPropEnt and in CS_DropWeapon safety checks.
1.1 --- a/extensions/cstrike/natives.cpp Mon Dec 17 14:33:57 2012 -0500
1.2 +++ b/extensions/cstrike/natives.cpp Mon Dec 17 14:34:44 2012 -0500
1.3 @@ -221,7 +221,7 @@
1.4 return pContext->ThrowNativeError("Invalid entity index %d for weapon", params[2]);
1.5
1.6 CBaseHandle &hndl = *(CBaseHandle *)((uint8_t *)pWeapon + spi.actual_offset);
1.7 - if (params[1] != hndl.GetEntryIndex())
1.8 + if (params[1] != hndl.GetEntryIndex() || hndl != ((IServerEntity *)pEntity)->GetRefEHandle())
1.9 return pContext->ThrowNativeError("Weapon %d is not owned by client %d", params[2], params[1]);
1.10
1.11 if (params[4] == 1 && g_pCSWeaponDropDetoured)
2.1 --- a/extensions/sdktools/gamerulesnatives.cpp Mon Dec 17 14:33:57 2012 -0500
2.2 +++ b/extensions/sdktools/gamerulesnatives.cpp Mon Dec 17 14:34:44 2012 -0500
2.3 @@ -339,9 +339,14 @@
2.4 void *pGameRules = *g_pGameRules;
2.5
2.6 CBaseHandle &hndl = *(CBaseHandle *)((intptr_t)pGameRules + offset);
2.7 + CBaseEntity *pEntity = gamehelpers->ReferenceToEntity(hndl.GetEntryIndex());
2.8
2.9 - int ref = gamehelpers->IndexToReference(hndl.GetEntryIndex());
2.10 - return gamehelpers->ReferenceToBCompatRef(ref);
2.11 + if (!pEntity || ((IServerEntity *)pEntity)->GetRefEHandle() != hndl)
2.12 + {
2.13 + return -1;
2.14 + }
2.15 +
2.16 + return gamehelpers->EntityToBCompatRef(pEntity);
2.17 }
2.18
2.19 static cell_t GameRules_SetPropEnt(IPluginContext *pContext, const cell_t *params)