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; \
|
||||
} \
|
||||
}
|
||||
|
Reference in New Issue
Block a user