From 6dba7c4f1727522b75578963923e8da58c406165 Mon Sep 17 00:00:00 2001 From: voed Date: Wed, 30 Jan 2019 16:19:30 +0200 Subject: [PATCH] Add player validation for menu_display (#671) Invalid player triggered crash because get/set_pdata is unsafe --- amxmodx/newmenus.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/amxmodx/newmenus.cpp b/amxmodx/newmenus.cpp index 9e07d356..e517ef6e 100755 --- a/amxmodx/newmenus.cpp +++ b/amxmodx/newmenus.cpp @@ -809,7 +809,20 @@ static cell AMX_NATIVE_CALL menu_display(AMX *amx, cell *params) int player = params[1]; int page = params[3]; + + if (player < 1 || player > gpGlobals->maxClients) + { + LogError(amx, AMX_ERR_NATIVE, "Invalid player id %d.", player); + return 0; + } + CPlayer* pPlayer = GET_PLAYER_POINTER_I(player); + + if (!pPlayer->ingame) + { + LogError(amx, AMX_ERR_NATIVE, "Player %d is not in game.", player); + return 0; + } if (!CloseNewMenus(pPlayer)) {