2
0
mirror of https://github.com/s1lentq/reapi.git synced 2024-10-16 23:37:07 +03:00

rg_round_end: add safe checks to index of bounds

This commit is contained in:
s1lent 2018-01-27 16:16:08 +07:00
parent c796cbf134
commit 59c8fca220
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C

View File

@ -379,7 +379,7 @@ struct {
const char *sentence;
size_t status;
} msg_sentence_list[] = {
{ "", "" }, // ROUND_NONE
{ "", "" }, // ROUND_NONE
{ "#Target_Bombed", "terwin", WINSTATUS_TERRORISTS }, // ROUND_TARGET_BOMB
{ "#VIP_Escaped", "ctwin", WINSTATUS_CTS }, // ROUND_VIP_ESCAPED
{ "#VIP_Assassinated", "terwin", WINSTATUS_TERRORISTS }, // ROUND_VIP_ASSASSINATED
@ -396,6 +396,8 @@ struct {
{ "#Terrorists_Not_Escaped", "ctwin", WINSTATUS_CTS }, // ROUND_TERRORISTS_NOT_ESCAPED
{ "#VIP_Not_Escaped", "terwin", WINSTATUS_TERRORISTS }, // ROUND_VIP_NOT_ESCAPED
{ "#Game_Commencing", "", WINSTATUS_DRAW }, // ROUND_GAME_COMMENCE
{ "", "", WINSTATUS_DRAW }, // ROUND_GAME_RESTART
{ "#Cstrike_Tutor_Round_Over", "rounddraw", WINSTATUS_DRAW }, // ROUND_GAME_OVER
};
/*
@ -427,7 +429,13 @@ cell AMX_NATIVE_CALL rg_round_end(AMX *amx, cell *params)
const char *message = getAmxString(amx, params[arg_message], messagebuf);
ScenarioEventEndRound event = static_cast<ScenarioEventEndRound>(params[arg_event]);
if (event != ROUND_NONE) {
if (event != ROUND_NONE)
{
if (event < ROUND_NONE || event > ROUND_GAME_OVER) {
AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: invalid event %i, bounds(%i, %i)", __FUNCTION__, event, ROUND_NONE, ROUND_GAME_OVER);
return FALSE;
}
auto& lst = msg_sentence_list[event];
if (strcmp(sentence, "default") == 0)
sentence = lst.sentence;