Add or adjust a bunch of safety checks (#433)
This commit is contained in:
@@ -882,7 +882,7 @@ static cell AMX_NATIVE_CALL cs_set_user_model(AMX *amx, cell *params)
|
||||
|
||||
GET_OFFSET("CBasePlayer", m_modelIndexPlayer);
|
||||
|
||||
char modelpath[260];
|
||||
char modelpath[PLATFORM_MAX_PATH];
|
||||
ke::SafeSprintf(modelpath, sizeof(modelpath), "models/player/%s/%s.mdl", newModel, newModel);
|
||||
|
||||
auto modelIndex = 0;
|
||||
|
@@ -13,12 +13,13 @@
|
||||
|
||||
#include "amxxmodule.h"
|
||||
#include <amtl/am-algorithm.h>
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
extern int MessageIdTextMsg;
|
||||
|
||||
bool UTIL_IsPlayer(edict_t *pPlayer)
|
||||
{
|
||||
return strcmp(STRING(pPlayer->v.classname), "player") == 0;
|
||||
return pPlayer && strcmp(STRING(pPlayer->v.classname), "player") == 0;
|
||||
}
|
||||
|
||||
void UTIL_TextMsg_Generic(edict_t* pPlayer, const char* message)
|
||||
@@ -36,7 +37,7 @@ bool UTIL_CheckForPublic(const char *publicname)
|
||||
int i = 0;
|
||||
char blah[64];
|
||||
|
||||
strncpy(blah, publicname, sizeof(blah) - 1);
|
||||
ke::SafeStrcpy(blah, sizeof(blah), publicname);
|
||||
|
||||
while ((amx = MF_GetScriptAmx(i++)))
|
||||
{
|
||||
|
@@ -49,6 +49,10 @@ void UTIL_StringToLower(const char *str, char *buffer, size_t maxlength);
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
|
||||
return 0; \
|
||||
} \
|
||||
else if (!MF_GetPlayerEdict(x)->pvPrivateData) { \
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (no private data)", x); \
|
||||
return 0; \
|
||||
} \
|
||||
} else { \
|
||||
if (x != 0 && FNullEnt(TypeConversion.id_to_edict(x))) { \
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
|
||||
@@ -62,8 +66,12 @@ void UTIL_StringToLower(const char *str, char *buffer, size_t maxlength);
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
|
||||
return 0; \
|
||||
} else { \
|
||||
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
|
||||
if (!MF_IsPlayerIngame(x)) { \
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
|
||||
return 0; \
|
||||
} \
|
||||
else if (!MF_GetPlayerEdict(x)->pvPrivateData) { \
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (no private data)", x); \
|
||||
return 0; \
|
||||
} \
|
||||
}
|
||||
|
@@ -178,14 +178,18 @@ void PlayerPreThink_Post( edict_t *pEntity ) {
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void ServerDeactivate() {
|
||||
void ServerDeactivate()
|
||||
{
|
||||
int i;
|
||||
for( i = 1;i<=gpGlobals->maxClients; ++i){
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
||||
if (pPlayer->rank) pPlayer->Disconnect();
|
||||
|
||||
for( i = 1; i <= gpGlobals->maxClients; ++i)
|
||||
{
|
||||
GET_PLAYER_POINTER_I(i)->Disconnect();
|
||||
}
|
||||
if ( (g_rank.getRankNum() >= (int)csstats_maxsize->value) || ((int)csstats_reset->value == 1 ) ) {
|
||||
CVAR_SET_FLOAT("csstats_reset",0.0);
|
||||
|
||||
if (static_cast<int>(csstats_maxsize->value) <= 0 || g_rank.getRankNum() >= static_cast<int>(csstats_maxsize->value) || static_cast<int>(csstats_reset->value) != 0)
|
||||
{
|
||||
CVAR_SET_FLOAT("csstats_reset", 0.0f);
|
||||
g_rank.clear(); // clear before save to file
|
||||
}
|
||||
g_rank.saveRank( MF_BuildPathname("%s",get_localinfo("csstats")) );
|
||||
@@ -197,27 +201,26 @@ void ServerDeactivate() {
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
BOOL ClientConnect_Post( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ){
|
||||
BOOL ClientConnect_Post( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128])
|
||||
{
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||
|
||||
if (pPlayer->pEdict == NULL)
|
||||
{
|
||||
pPlayer->Init(ENTINDEX(pEntity), pEntity);
|
||||
}
|
||||
|
||||
pPlayer->Connect(pszAddress);
|
||||
|
||||
RETURN_META_VALUE(MRES_IGNORED, TRUE);
|
||||
}
|
||||
|
||||
void ClientDisconnect( edict_t *pEntity ) {
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
|
||||
if (pPlayer->rank) pPlayer->Disconnect();
|
||||
void ClientDisconnect( edict_t *pEntity )
|
||||
{
|
||||
GET_PLAYER_POINTER(pEntity)->Disconnect();
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void ClientPutInServer_Post( edict_t *pEntity ) {
|
||||
void ClientPutInServer_Post( edict_t *pEntity )
|
||||
{
|
||||
GET_PLAYER_POINTER(pEntity)->PutInServer();
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user