Added many missing handle security checks (bug 5595, r=psychonic).
1.1 --- a/core/logic/smn_functions.cpp Thu Jul 18 20:34:11 2013 -0400
1.2 +++ b/core/logic/smn_functions.cpp Thu Jul 18 20:34:43 2013 -0400
1.3 @@ -187,8 +187,9 @@
1.4 Handle_t hndl = static_cast<Handle_t>(params[1]);
1.5 HandleError err;
1.6 IForward *pForward;
1.7 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
1.8
1.9 - if ((err=handlesys->ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward))
1.10 + if ((err=handlesys->ReadHandle(hndl, g_GlobalFwdType, &sec, (void **)&pForward))
1.11 != HandleError_None)
1.12 {
1.13 return pContext->ThrowNativeError("Invalid forward handle %x (error %d)", hndl, err);
1.14 @@ -204,8 +205,9 @@
1.15 HandleError err;
1.16 IChangeableForward *pForward;
1.17 IPlugin *pPlugin;
1.18 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
1.19
1.20 - if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
1.21 + if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, &sec, (void **)&pForward))
1.22 != HandleError_None)
1.23 {
1.24 return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err);
1.25 @@ -240,8 +242,9 @@
1.26 HandleError err;
1.27 IChangeableForward *pForward;
1.28 IPlugin *pPlugin;
1.29 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
1.30
1.31 - if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
1.32 + if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, &sec, (void **)&pForward))
1.33 != HandleError_None)
1.34 {
1.35 return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err);
1.36 @@ -276,8 +279,9 @@
1.37 HandleError err;
1.38 IChangeableForward *pForward;
1.39 IPlugin *pPlugin;
1.40 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
1.41
1.42 - if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, NULL, (void **)&pForward))
1.43 + if ((err=handlesys->ReadHandle(fwdHandle, g_PrivateFwdType, &sec, (void **)&pForward))
1.44 != HandleError_None)
1.45 {
1.46 return pContext->ThrowNativeError("Invalid private forward handle %x (error %d)", fwdHandle, err);
1.47 @@ -339,12 +343,13 @@
1.48 Handle_t hndl;
1.49 HandleError err;
1.50 IForward *pForward;
1.51 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
1.52
1.53 ResetCall();
1.54
1.55 hndl = static_cast<Handle_t>(params[1]);
1.56
1.57 - if ((err=handlesys->ReadHandle(hndl, g_GlobalFwdType, NULL, (void **)&pForward))
1.58 + if ((err=handlesys->ReadHandle(hndl, g_GlobalFwdType, &sec, (void **)&pForward))
1.59 != HandleError_None)
1.60 {
1.61 return pContext->ThrowNativeError("Invalid forward handle %x (error %d)", hndl, err);
2.1 --- a/core/logic/smn_textparse.cpp Thu Jul 18 20:34:11 2013 -0400
2.2 +++ b/core/logic/smn_textparse.cpp Thu Jul 18 20:34:43 2013 -0400
2.3 @@ -202,8 +202,9 @@
2.4 Handle_t hndl = (Handle_t)params[1];
2.5 HandleError err;
2.6 ParseInfo *parse;
2.7 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
2.8
2.9 - if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
2.10 + if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, &sec, (void **)&parse))
2.11 != HandleError_None)
2.12 {
2.13 return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
2.14 @@ -219,8 +220,9 @@
2.15 Handle_t hndl = (Handle_t)params[1];
2.16 HandleError err;
2.17 ParseInfo *parse;
2.18 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
2.19
2.20 - if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
2.21 + if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, &sec, (void **)&parse))
2.22 != HandleError_None)
2.23 {
2.24 return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
2.25 @@ -236,8 +238,9 @@
2.26 Handle_t hndl = (Handle_t)params[1];
2.27 HandleError err;
2.28 ParseInfo *parse;
2.29 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
2.30
2.31 - if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
2.32 + if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, &sec, (void **)&parse))
2.33 != HandleError_None)
2.34 {
2.35 return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
2.36 @@ -255,8 +258,9 @@
2.37 Handle_t hndl = (Handle_t)params[1];
2.38 HandleError err;
2.39 ParseInfo *parse;
2.40 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
2.41
2.42 - if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
2.43 + if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, &sec, (void **)&parse))
2.44 != HandleError_None)
2.45 {
2.46 return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
2.47 @@ -272,8 +276,9 @@
2.48 Handle_t hndl = (Handle_t)params[1];
2.49 HandleError err;
2.50 ParseInfo *parse;
2.51 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
2.52
2.53 - if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, NULL, (void **)&parse))
2.54 + if ((err=handlesys->ReadHandle(hndl, g_TypeSMC, &sec, (void **)&parse))
2.55 != HandleError_None)
2.56 {
2.57 return pContext->ThrowNativeError("Invalid SMC Parse Handle %x (error %d)", hndl, err);
3.1 --- a/core/smn_events.cpp Thu Jul 18 20:34:11 2013 -0400
3.2 +++ b/core/smn_events.cpp Thu Jul 18 20:34:43 2013 -0400
3.3 @@ -124,8 +124,9 @@
3.4 Handle_t hndl = static_cast<Handle_t>(params[1]);
3.5 HandleError err;
3.6 EventInfo *pInfo;
3.7 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
3.8
3.9 - if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
3.10 + if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
3.11 != HandleError_None)
3.12 {
3.13 return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
3.14 @@ -140,7 +141,6 @@
3.15 g_EventManager.FireEvent(pInfo, params[2] ? true : false);
3.16
3.17 /* Free handle on game event */
3.18 - HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
3.19 handlesys->FreeHandle(hndl, &sec);
3.20
3.21 return 1;
3.22 @@ -151,8 +151,9 @@
3.23 Handle_t hndl = static_cast<Handle_t>(params[1]);
3.24 HandleError err;
3.25 EventInfo *pInfo;
3.26 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
3.27
3.28 - if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
3.29 + if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
3.30 != HandleError_None)
3.31 {
3.32 return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
3.33 @@ -167,7 +168,6 @@
3.34 g_EventManager.CancelCreatedEvent(pInfo);
3.35
3.36 /* Free handle on game event */
3.37 - HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
3.38 handlesys->FreeHandle(hndl, &sec);
3.39
3.40 return 1;
3.41 @@ -178,8 +178,9 @@
3.42 Handle_t hndl = static_cast<Handle_t>(params[1]);
3.43 HandleError err;
3.44 EventInfo *pInfo;
3.45 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
3.46
3.47 - if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
3.48 + if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
3.49 != HandleError_None)
3.50 {
3.51 return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
3.52 @@ -195,8 +196,9 @@
3.53 Handle_t hndl = static_cast<Handle_t>(params[1]);
3.54 HandleError err;
3.55 EventInfo *pInfo;
3.56 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
3.57
3.58 - if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
3.59 + if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
3.60 != HandleError_None)
3.61 {
3.62 return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
3.63 @@ -213,8 +215,9 @@
3.64 Handle_t hndl = static_cast<Handle_t>(params[1]);
3.65 HandleError err;
3.66 EventInfo *pInfo;
3.67 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
3.68
3.69 - if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
3.70 + if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
3.71 != HandleError_None)
3.72 {
3.73 return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
3.74 @@ -231,8 +234,9 @@
3.75 Handle_t hndl = static_cast<Handle_t>(params[1]);
3.76 HandleError err;
3.77 EventInfo *pInfo;
3.78 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
3.79
3.80 - if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
3.81 + if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
3.82 != HandleError_None)
3.83 {
3.84 return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
3.85 @@ -251,8 +255,9 @@
3.86 Handle_t hndl = static_cast<Handle_t>(params[1]);
3.87 HandleError err;
3.88 EventInfo *pInfo;
3.89 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
3.90
3.91 - if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
3.92 + if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
3.93 != HandleError_None)
3.94 {
3.95 return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
3.96 @@ -271,8 +276,9 @@
3.97 Handle_t hndl = static_cast<Handle_t>(params[1]);
3.98 HandleError err;
3.99 EventInfo *pInfo;
3.100 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
3.101
3.102 - if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
3.103 + if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
3.104 != HandleError_None)
3.105 {
3.106 return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
3.107 @@ -291,8 +297,9 @@
3.108 Handle_t hndl = static_cast<Handle_t>(params[1]);
3.109 HandleError err;
3.110 EventInfo *pInfo;
3.111 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
3.112
3.113 - if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
3.114 + if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
3.115 != HandleError_None)
3.116 {
3.117 return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
3.118 @@ -311,8 +318,9 @@
3.119 Handle_t hndl = static_cast<Handle_t>(params[1]);
3.120 HandleError err;
3.121 EventInfo *pInfo;
3.122 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
3.123
3.124 - if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
3.125 + if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
3.126 != HandleError_None)
3.127 {
3.128 return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
3.129 @@ -332,8 +340,9 @@
3.130 Handle_t hndl = static_cast<Handle_t>(params[1]);
3.131 HandleError err;
3.132 EventInfo *pInfo;
3.133 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
3.134
3.135 - if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
3.136 + if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
3.137 != HandleError_None)
3.138 {
3.139 return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);
3.140 @@ -353,8 +362,9 @@
3.141 Handle_t hndl = static_cast<Handle_t>(params[1]);
3.142 HandleError err;
3.143 EventInfo *pInfo;
3.144 + HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
3.145
3.146 - if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), NULL, (void **)&pInfo))
3.147 + if ((err=handlesys->ReadHandle(hndl, g_EventManager.GetHandleType(), &sec, (void **)&pInfo))
3.148 != HandleError_None)
3.149 {
3.150 return pContext->ThrowNativeError("Invalid game event handle %x (error %d)", hndl, err);