Added many missing handle security checks (bug 5595, r=psychonic).

--HG--
extra : rebase_source : cc5bf3057bbce89fc14bff9c673821c3146c588b
This commit is contained in:
Kyle Sanderson 2013-07-18 20:34:43 -04:00
parent 4661e5a10b
commit b3c0b964b5
3 changed files with 44 additions and 24 deletions

View File

@ -187,8 +187,9 @@ static cell_t sm_GetForwardFunctionCount(IPluginContext *pContext, const cell_t
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
IForward *pForward;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward))
if ((err=handlesys->ReadHandle(hndl, g_GlobalFwdType, &sec, (void **)&pForward))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid forward handle %x (error %d)", hndl, err);
@ -204,8 +205,9 @@ static cell_t sm_AddToForward(IPluginContext *pContext, const cell_t *params)
HandleError err;
IChangeableForward *pForward;
IPlugin *pPlugin;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, &sec, (void **)&pForward))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err);
@ -240,8 +242,9 @@ static cell_t sm_RemoveFromForward(IPluginContext *pContext, const cell_t *param
HandleError err;
IChangeableForward *pForward;
IPlugin *pPlugin;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, &sec, (void **)&pForward))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err);
@ -276,8 +279,9 @@ static cell_t sm_RemoveAllFromForward(IPluginContext *pContext, const cell_t *pa
HandleError err;
IChangeableForward *pForward;
IPlugin *pPlugin;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, &sec, (void **)&pForward))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err);
@ -339,12 +343,13 @@ static cell_t sm_CallStartForward(IPluginContext *pContext, const cell_t *params
Handle_t hndl;
HandleError err;
IForward *pForward;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
ResetCall();
hndl = static_cast<Handle_t>(params[1]);
if ((err=handlesys->ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward))
if ((err=handlesys->ReadHandle(hndl, g_GlobalFwdType, &sec, (void **)&pForward))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid forward handle %x (error %d)", hndl, err);

View File

@ -202,8 +202,9 @@ static cell_t SMC_SetParseStart(IPluginContext *pContext, const cell_t *params)
Handle_t hndl = (Handle_t)params[1];
HandleError err;
ParseInfo *parse;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, &sec, (void **)&parse))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
@ -219,8 +220,9 @@ static cell_t SMC_SetParseEnd(IPluginContext *pContext, const cell_t *params)
Handle_t hndl = (Handle_t)params[1];
HandleError err;
ParseInfo *parse;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, &sec, (void **)&parse))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
@ -236,8 +238,9 @@ static cell_t SMC_SetReaders(IPluginContext *pContext, const cell_t *params)
Handle_t hndl = (Handle_t)params[1];
HandleError err;
ParseInfo *parse;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, &sec, (void **)&parse))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
@ -255,8 +258,9 @@ static cell_t SMC_SetRawLine(IPluginContext *pContext, const cell_t *params)
Handle_t hndl = (Handle_t)params[1];
HandleError err;
ParseInfo *parse;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, &sec, (void **)&parse))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
@ -272,8 +276,9 @@ static cell_t SMC_ParseFile(IPluginContext *pContext, const cell_t *params)
Handle_t hndl = (Handle_t)params[1];
HandleError err;
ParseInfo *parse;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, &sec, (void **)&parse))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);

View File

@ -124,8 +124,9 @@ static cell_t sm_FireEvent(IPluginContext *pContext, const cell_t *params)
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
EventInfo *pInfo;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -140,7 +141,6 @@ static cell_t sm_FireEvent(IPluginContext *pContext, const cell_t *params)
g_EventManager.FireEvent(pInfo, params[2] ? true : false);
/* Free handle on game event */
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
handlesys->FreeHandle(hndl, &sec);
return 1;
@ -151,8 +151,9 @@ static cell_t sm_CancelCreatedEvent(IPluginContext *pContext, const cell_t *para
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
EventInfo *pInfo;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -167,7 +168,6 @@ static cell_t sm_CancelCreatedEvent(IPluginContext *pContext, const cell_t *para
g_EventManager.CancelCreatedEvent(pInfo);
/* Free handle on game event */
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
handlesys->FreeHandle(hndl, &sec);
return 1;
@ -178,8 +178,9 @@ static cell_t sm_GetEventName(IPluginContext *pContext, const cell_t *params)
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
EventInfo *pInfo;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -195,8 +196,9 @@ static cell_t sm_GetEventBool(IPluginContext *pContext, const cell_t *params)
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
EventInfo *pInfo;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -213,8 +215,9 @@ static cell_t sm_GetEventInt(IPluginContext *pContext, const cell_t *params)
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
EventInfo *pInfo;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -231,8 +234,9 @@ static cell_t sm_GetEventFloat(IPluginContext *pContext, const cell_t *params)
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
EventInfo *pInfo;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -251,8 +255,9 @@ static cell_t sm_GetEventString(IPluginContext *pContext, const cell_t *params)
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
EventInfo *pInfo;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -271,8 +276,9 @@ static cell_t sm_SetEventBool(IPluginContext *pContext, const cell_t *params)
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
EventInfo *pInfo;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -291,8 +297,9 @@ static cell_t sm_SetEventInt(IPluginContext *pContext, const cell_t *params)
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
EventInfo *pInfo;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -311,8 +318,9 @@ static cell_t sm_SetEventFloat(IPluginContext *pContext, const cell_t *params)
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
EventInfo *pInfo;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -332,8 +340,9 @@ static cell_t sm_SetEventString(IPluginContext *pContext, const cell_t *params)
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
EventInfo *pInfo;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
@ -353,8 +362,9 @@ static cell_t sm_SetEventBroadcast(IPluginContext *pContext, const cell_t *param
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError err;
EventInfo *pInfo;
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);