All natives that use a recipient filter now actually validate the clients passed to them.
This includes StartMessage(), StartMessageEx() from Core as well as EmitSound(), EmitSentence(), and TE_Send() from SDKTools (Warning: This may potentially cause a minor compatibility problem with plugins that don't check client validity before passing to these natives) --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402252
This commit is contained in:
@@ -445,10 +445,29 @@ static cell_t smn_TESend(IPluginContext *pContext, const cell_t *params)
|
||||
}
|
||||
|
||||
cell_t *cl_array;
|
||||
unsigned int numClients;
|
||||
int client;
|
||||
IGamePlayer *pPlayer = NULL;
|
||||
|
||||
pContext->LocalToPhysAddr(params[1], &cl_array);
|
||||
numClients = params[2];
|
||||
|
||||
/* Client validation */
|
||||
for (unsigned int i = 0; i < numClients; i++)
|
||||
{
|
||||
client = cl_array[i];
|
||||
pPlayer = playerhelpers->GetGamePlayer(client);
|
||||
|
||||
if (!pPlayer)
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
} else if (!pPlayer->IsInGame()) {
|
||||
return pContext->ThrowNativeError("Client %d is not connected", client);
|
||||
}
|
||||
}
|
||||
|
||||
g_TERecFilter.Reset();
|
||||
g_TERecFilter.Initialize(cl_array, params[2]);
|
||||
g_TERecFilter.Initialize(cl_array, numClients);
|
||||
|
||||
g_CurrentTE->Send(g_TERecFilter, sp_ctof(params[3]));
|
||||
g_CurrentTE = NULL;
|
||||
|
||||
@@ -449,11 +449,30 @@ static cell_t StopSound(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
static cell_t EmitSound(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
cell_t *addr, *pl_addr;
|
||||
|
||||
cell_t *addr, *cl_array;
|
||||
CellRecipientFilter crf;
|
||||
pContext->LocalToPhysAddr(params[1], &pl_addr);
|
||||
crf.Initialize(pl_addr, params[2]);
|
||||
unsigned int numClients;
|
||||
int client;
|
||||
IGamePlayer *pPlayer = NULL;
|
||||
|
||||
pContext->LocalToPhysAddr(params[1], &cl_array);
|
||||
numClients = params[2];
|
||||
|
||||
/* Client validation */
|
||||
for (unsigned int i = 0; i < numClients; i++)
|
||||
{
|
||||
client = cl_array[i];
|
||||
pPlayer = playerhelpers->GetGamePlayer(client);
|
||||
|
||||
if (!pPlayer)
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
} else if (!pPlayer->IsInGame()) {
|
||||
return pContext->ThrowNativeError("Client %d is not connected", client);
|
||||
}
|
||||
}
|
||||
|
||||
crf.Initialize(cl_array, numClients);
|
||||
|
||||
char *sample;
|
||||
pContext->LocalToString(params[3], &sample);
|
||||
@@ -512,10 +531,10 @@ static cell_t EmitSound(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
if (entity == -2 && engine->IsDedicatedServer())
|
||||
{
|
||||
for (cell_t i=0; i<params[2]; i++)
|
||||
for (unsigned int i = 0; i < numClients; i++)
|
||||
{
|
||||
cell_t player[1];
|
||||
player[0] = pl_addr[i];
|
||||
player[0] = cl_array[i];
|
||||
crf.Reset();
|
||||
crf.Initialize(player, 1);
|
||||
if (g_InSoundHook)
|
||||
@@ -604,10 +623,29 @@ static cell_t EmitSound(IPluginContext *pContext, const cell_t *params)
|
||||
static cell_t EmitSentence(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
cell_t *addr;
|
||||
|
||||
CellRecipientFilter crf;
|
||||
unsigned int numClients;
|
||||
int client;
|
||||
IGamePlayer *pPlayer = NULL;
|
||||
|
||||
pContext->LocalToPhysAddr(params[1], &addr);
|
||||
crf.Initialize(addr, params[2]);
|
||||
numClients = params[2];
|
||||
|
||||
/* Client validation */
|
||||
for (unsigned int i = 0; i < numClients; i++)
|
||||
{
|
||||
client = addr[i];
|
||||
pPlayer = playerhelpers->GetGamePlayer(client);
|
||||
|
||||
if (!pPlayer)
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
} else if (!pPlayer->IsInGame()) {
|
||||
return pContext->ThrowNativeError("Client %d is not connected", client);
|
||||
}
|
||||
}
|
||||
|
||||
crf.Initialize(addr, numClients);
|
||||
|
||||
int sentence = params[3];
|
||||
int entity = params[4];
|
||||
|
||||
Reference in New Issue
Block a user