From 5139eef1830b930777d9c71a0dd39cef421029cf Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Wed, 3 Jun 2015 22:28:58 -0400 Subject: [PATCH 1/2] Fix buffer sizes used for map names (64 -> MAX_PATH). As more games are now supporting maps nested in subfolders or in folders outside of the maps folder, we need to account for the full path that the game uses to refer to the map for compatibility. Many other places for fixed for this already after CS:GO added Steam Workshop support for maps. --- plugins/basevotes/votemap.sp | 6 +++--- plugins/nextmap.sp | 12 ++++++------ plugins/nominations.sp | 14 +++++++------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/plugins/basevotes/votemap.sp b/plugins/basevotes/votemap.sp index 58fba333..b1b643c2 100644 --- a/plugins/basevotes/votemap.sp +++ b/plugins/basevotes/votemap.sp @@ -109,7 +109,7 @@ public MenuHandler_Confirm(Menu menu, MenuAction action, int param1, int param2) } else if (action == MenuAction_Select) { - decl String:maps[5][64]; + decl String:maps[5][PLATFORM_MAX_PATH]; new selectedmaps = GetArraySize(g_SelectedMaps); for (new i = 0; i < selectedmaps; i++) @@ -233,7 +233,7 @@ public Action:Command_Votemap(client, args) decl String:text[256]; GetCmdArgString(text, sizeof(text)); - decl String:maps[5][64]; + decl String:maps[5][PLATFORM_MAX_PATH]; new mapCount; new len, pos; @@ -283,7 +283,7 @@ int LoadMapList(Menu menu) RemoveAllMenuItems(menu); - char map_name[64]; + char map_name[PLATFORM_MAX_PATH]; new map_count = GetArraySize(g_map_array); for (new i = 0; i < map_count; i++) diff --git a/plugins/nextmap.sp b/plugins/nextmap.sp index accd8339..155da05e 100644 --- a/plugins/nextmap.sp +++ b/plugins/nextmap.sp @@ -86,8 +86,8 @@ public void OnPluginStart() RegConsoleCmd("listmaps", Command_List); // Set to the current map so OnMapStart() will know what to do - char currentMap[64]; - GetCurrentMap(currentMap, 64); + char currentMap[PLATFORM_MAX_PATH]; + GetCurrentMap(currentMap, sizeof(currentMap)); SetNextMap(currentMap); } @@ -98,9 +98,9 @@ public void OnMapStart() public void OnConfigsExecuted() { - char lastMap[64], currentMap[64]; + char lastMap[PLATFORM_MAX_PATH], currentMap[PLATFORM_MAX_PATH]; GetNextMap(lastMap, sizeof(lastMap)); - GetCurrentMap(currentMap, 64); + GetCurrentMap(currentMap, sizeof(currentMap)); // Why am I doing this? If we switched to a new map, but it wasn't what we expected (Due to sm_map, sm_votemap, or // some other plugin/command), we don't want to scramble the map cycle. Or for example, admin switches to a custom map @@ -146,8 +146,8 @@ void FindAndSetNextMap() if (g_MapPos == -1) { - char current[64]; - GetCurrentMap(current, 64); + char current[PLATFORM_MAX_PATH]; + GetCurrentMap(current, sizeof(current)); for (int i = 0; i < mapCount; i++) { diff --git a/plugins/nominations.sp b/plugins/nominations.sp index b142fc18..f20ed1fa 100644 --- a/plugins/nominations.sp +++ b/plugins/nominations.sp @@ -123,7 +123,7 @@ public Action Command_Addmap(int client, int args) return Plugin_Handled; } - char mapname[64]; + char mapname[PLATFORM_MAX_PATH]; GetCmdArg(1, mapname, sizeof(mapname)); @@ -184,7 +184,7 @@ public Action Command_Nominate(int client, int args) return Plugin_Handled; } - char mapname[64]; + char mapname[PLATFORM_MAX_PATH]; GetCmdArg(1, mapname, sizeof(mapname)); int status; @@ -257,10 +257,10 @@ void BuildMapMenu() g_MapMenu = new Menu(Handler_MapSelectMenu, MENU_ACTIONS_DEFAULT|MenuAction_DrawItem|MenuAction_DisplayItem); - char map[64]; + char map[PLATFORM_MAX_PATH]; ArrayList excludeMaps; - char currentMap[32]; + char currentMap[PLATFORM_MAX_PATH]; if (g_Cvar_ExcludeOld.BoolValue) { @@ -312,7 +312,7 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p { case MenuAction_Select: { - char map[64], name[64]; + char map[PLATFORM_MAX_PATH], name[64]; menu.GetItem(param2, map, sizeof(map)); GetClientName(param1, name, 64); @@ -344,7 +344,7 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p case MenuAction_DrawItem: { - char map[64]; + char map[PLATFORM_MAX_PATH]; menu.GetItem(param2, map, sizeof(map)); int status; @@ -366,7 +366,7 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p case MenuAction_DisplayItem: { - char map[64]; + char map[PLATFORM_MAX_PATH]; menu.GetItem(param2, map, sizeof(map)); int status; From 9e0dbfcf6807c0782a6a8eea079bd14afe24c74d Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Wed, 3 Jun 2015 22:40:43 -0400 Subject: [PATCH 2/2] Fix inconsistencies with buffer sizes for player names. Found any I could not using MAX_NAME_LENGTH and changed them to use it. I think that we should increase MAX_NAME_LENGTH to 128 for CS:GO at some point as that's what it uses internally. (Presumably to get the client's full multibyte name from Steam without truncation mid-codepoint which can happen in other games. Steam's max is 32 characters if I remember correctly, but allows multibyte chars). --- plugins/admin-sql-threaded.sp | 4 ++-- plugins/basebans/ban.sp | 2 +- plugins/funcommands/beacon.sp | 2 +- plugins/funcommands/blind.sp | 2 +- plugins/funcommands/drug.sp | 2 +- plugins/funcommands/fire.sp | 6 +++--- plugins/funcommands/gravity.sp | 2 +- plugins/funcommands/ice.sp | 6 +++--- plugins/funcommands/noclip.sp | 2 +- plugins/funcommands/timebomb.sp | 4 ++-- plugins/funvotes.sp | 2 +- plugins/include/helpers.inc | 6 +++--- plugins/nominations.sp | 6 +++--- plugins/playercommands/slap.sp | 2 +- plugins/playercommands/slay.sp | 2 +- plugins/rockthevote.sp | 2 +- 16 files changed, 26 insertions(+), 26 deletions(-) diff --git a/plugins/admin-sql-threaded.sp b/plugins/admin-sql-threaded.sp index b1c0fa73..e65a1a64 100644 --- a/plugins/admin-sql-threaded.sp +++ b/plugins/admin-sql-threaded.sp @@ -457,8 +457,8 @@ public void OnReceiveUser(Database db, DBResultSet rs, const char[] error, any d void FetchUser(Database db, int client) { - char name[65]; - char safe_name[140]; + char name[MAX_NAME_LENGTH]; + char safe_name[(MAX_NAME_LENGTH * 2) - 1]; char steamid[32]; char steamidalt[32]; char ipaddr[24]; diff --git a/plugins/basebans/ban.sp b/plugins/basebans/ban.sp index 2ce3320f..2b4fdfc1 100644 --- a/plugins/basebans/ban.sp +++ b/plugins/basebans/ban.sp @@ -49,7 +49,7 @@ PrepareBan(client, target, time, const String:reason[]) return; } - new String:name[32]; + new String:name[MAX_NAME_LENGTH]; GetClientName(target, name, sizeof(name)); if (!time) diff --git a/plugins/funcommands/beacon.sp b/plugins/funcommands/beacon.sp index bb4fe3da..cb720543 100644 --- a/plugins/funcommands/beacon.sp +++ b/plugins/funcommands/beacon.sp @@ -184,7 +184,7 @@ public MenuHandler_Beacon(Menu menu, MenuAction action, int param1, int param2) } else { - new String:name[32]; + new String:name[MAX_NAME_LENGTH]; GetClientName(target, name, sizeof(name)); PerformBeacon(param1, target); diff --git a/plugins/funcommands/blind.sp b/plugins/funcommands/blind.sp index 77842438..9028a288 100644 --- a/plugins/funcommands/blind.sp +++ b/plugins/funcommands/blind.sp @@ -208,7 +208,7 @@ public MenuHandler_Amount(Menu menu, MenuAction action, int param1, int param2) } else { - new String:name[32]; + new String:name[MAX_NAME_LENGTH]; GetClientName(target, name, sizeof(name)); PerformBlind(param1, target, amount); diff --git a/plugins/funcommands/drug.sp b/plugins/funcommands/drug.sp index 5750abb5..fb623033 100644 --- a/plugins/funcommands/drug.sp +++ b/plugins/funcommands/drug.sp @@ -265,7 +265,7 @@ public MenuHandler_Drug(Menu menu, MenuAction action, int param1, int param2) } else { - new String:name[32]; + new String:name[MAX_NAME_LENGTH]; GetClientName(target, name, sizeof(name)); PerformDrug(param1, target, 2); diff --git a/plugins/funcommands/fire.sp b/plugins/funcommands/fire.sp index 03eaec4f..8126ad93 100644 --- a/plugins/funcommands/fire.sp +++ b/plugins/funcommands/fire.sp @@ -125,7 +125,7 @@ public Action:Timer_FireBomb(Handle:timer, any:value) SetEntityRenderColor(client, 255, color, color, 255); - char name[64]; + char name[MAX_NAME_LENGTH]; GetClientName(client, name, sizeof(name)); PrintCenterTextAll("%t", "Till Explodes", name, g_FireBombTime[client]); @@ -304,7 +304,7 @@ public MenuHandler_Burn(Menu menu, MenuAction action, int param1, int param2) } else { - new String:name[32]; + new String:name[MAX_NAME_LENGTH]; GetClientName(target, name, sizeof(name)); PerformBurn(param1, target, 20.0); ShowActivity2(param1, "[SM] ", "%t", "Set target on fire", "_s", name); @@ -349,7 +349,7 @@ public MenuHandler_FireBomb(Menu menu, MenuAction action, int param1, int param2 } else { - new String:name[32]; + new String:name[MAX_NAME_LENGTH]; GetClientName(target, name, sizeof(name)); PerformFireBomb(param1, target); diff --git a/plugins/funcommands/gravity.sp b/plugins/funcommands/gravity.sp index 1ac7584c..341e3a2e 100644 --- a/plugins/funcommands/gravity.sp +++ b/plugins/funcommands/gravity.sp @@ -165,7 +165,7 @@ public MenuHandler_GravityAmount(Menu menu, MenuAction action, int param1, int p } else { - new String:name[32]; + new String:name[MAX_NAME_LENGTH]; GetClientName(target, name, sizeof(name)); PerformGravity(param1, target, amount); diff --git a/plugins/funcommands/ice.sp b/plugins/funcommands/ice.sp index 3f55c567..e8d2e6cb 100644 --- a/plugins/funcommands/ice.sp +++ b/plugins/funcommands/ice.sp @@ -246,7 +246,7 @@ public Action:Timer_FreezeBomb(Handle:timer, any:value) SetEntityRenderColor(client, color, color, 255, 255); - char name[64]; + char name[MAX_NAME_LENGTH]; GetClientName(client, name, sizeof(name)); PrintCenterTextAll("%t", "Till Explodes", name, g_FreezeBombTime[client]); @@ -418,7 +418,7 @@ public MenuHandler_Freeze(Menu menu, MenuAction action, int param1, int param2) } else { - new String:name[32]; + new String:name[MAX_NAME_LENGTH]; GetClientName(target, name, sizeof(name)); PerformFreeze(param1, target, g_Cvar_FreezeDuration.IntValue); @@ -464,7 +464,7 @@ public MenuHandler_FreezeBomb(Menu menu, MenuAction action, int param1, int para } else { - new String:name[32]; + new String:name[MAX_NAME_LENGTH]; GetClientName(target, name, sizeof(name)); PerformFreezeBomb(param1, target); diff --git a/plugins/funcommands/noclip.sp b/plugins/funcommands/noclip.sp index d259daea..263979e8 100644 --- a/plugins/funcommands/noclip.sp +++ b/plugins/funcommands/noclip.sp @@ -109,7 +109,7 @@ public MenuHandler_NoClip(Menu menu, MenuAction action, int param1, int param2) } else { - new String:name[32]; + new String:name[MAX_NAME_LENGTH]; GetClientName(target, name, sizeof(name)); PerformNoClip(param1, target); diff --git a/plugins/funcommands/timebomb.sp b/plugins/funcommands/timebomb.sp index 8f41fce2..d0da8fb1 100644 --- a/plugins/funcommands/timebomb.sp +++ b/plugins/funcommands/timebomb.sp @@ -118,7 +118,7 @@ public Action:Timer_TimeBomb(Handle:timer, any:value) SetEntityRenderColor(client, 255, 128, color, 255); - char name[64]; + char name[MAX_NAME_LENGTH]; GetClientName(client, name, sizeof(name)); PrintCenterTextAll("%t", "Till Explodes", name, g_TimeBombTime[client]); @@ -275,7 +275,7 @@ public MenuHandler_TimeBomb(Menu menu, MenuAction action, int param1, int param2 } else { - new String:name[32]; + new String:name[MAX_NAME_LENGTH]; GetClientName(target, name, sizeof(name)); PerformTimeBomb(param1, target); diff --git a/plugins/funvotes.sp b/plugins/funvotes.sp index 43753eb4..ae3afef6 100644 --- a/plugins/funvotes.sp +++ b/plugins/funvotes.sp @@ -283,7 +283,7 @@ VoteSelect(Handle:menu, param1, param2 = 0) { if (GetConVarInt(g_Cvar_VoteShow) == 1) { - decl String:voter[64], String:junk[64], String:choice[64]; + decl String:voter[MAX_NAME_LENGTH], String:junk[64], String:choice[64]; GetClientName(param1, voter, sizeof(voter)); menu.GetItem(param2, junk, sizeof(junk), _, choice, sizeof(choice)); PrintToChatAll("[SM] %T", "Vote Select", LANG_SERVER, voter, choice); diff --git a/plugins/include/helpers.inc b/plugins/include/helpers.inc index d30c3853..ea1f915f 100644 --- a/plugins/include/helpers.inc +++ b/plugins/include/helpers.inc @@ -46,7 +46,7 @@ stock FormatUserLogText(client, String:buffer[], maxlength) { decl String:auth[32]; - decl String:name[40]; + decl String:name[MAX_NAME_LENGTH]; new userid = GetClientUserId(client); if (!GetClientAuthString(client, auth, sizeof(auth))) @@ -107,7 +107,7 @@ stock int SearchForClients(const char[] pattern, int[] clients, int maxClients) if (pattern[0] == '#') { int input = StringToInt(pattern[1]); if (!input) { - char name[65]; + char name[MAX_NAME_LENGTH]; for (int i=1; i<=MaxClients; i++) { if (!IsClientInGame(i)) continue; @@ -126,7 +126,7 @@ stock int SearchForClients(const char[] pattern, int[] clients, int maxClients) } } - char name[65]; + char name[MAX_NAME_LENGTH]; for (int i=1; i<=MaxClients; i++) { if (!IsClientInGame(i)) diff --git a/plugins/nominations.sp b/plugins/nominations.sp index f20ed1fa..9f9f5c36 100644 --- a/plugins/nominations.sp +++ b/plugins/nominations.sp @@ -234,7 +234,7 @@ public Action Command_Nominate(int client, int args) g_mapTrie.SetValue(mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED); - char name[64]; + char name[MAX_NAME_LENGTH]; GetClientName(client, name, sizeof(name)); PrintToChatAll("[SM] %t", "Map Nominated", name, mapname); @@ -312,10 +312,10 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p { case MenuAction_Select: { - char map[PLATFORM_MAX_PATH], name[64]; + char map[PLATFORM_MAX_PATH], name[MAX_NAME_LENGTH]; menu.GetItem(param2, map, sizeof(map)); - GetClientName(param1, name, 64); + GetClientName(param1, name, sizeof(name)); NominateResult result = NominateMap(map, false, param1); diff --git a/plugins/playercommands/slap.sp b/plugins/playercommands/slap.sp index c561f54e..8ea3f9eb 100644 --- a/plugins/playercommands/slap.sp +++ b/plugins/playercommands/slap.sp @@ -149,7 +149,7 @@ public MenuHandler_Slap(Menu menu, MenuAction action, int param1, int param2) } else { - decl String:name[32]; + decl String:name[MAX_NAME_LENGTH]; GetClientName(target, name, sizeof(name)); PerformSlap(param1, target, g_SlapDamage[param1]); ShowActivity2(param1, "[SM] ", "%t", "Slapped target", "_s", name); diff --git a/plugins/playercommands/slay.sp b/plugins/playercommands/slay.sp index e5f19290..e024a698 100644 --- a/plugins/playercommands/slay.sp +++ b/plugins/playercommands/slay.sp @@ -103,7 +103,7 @@ public MenuHandler_Slay(Menu menu, MenuAction action, param1, param2) } else { - decl String:name[32]; + decl String:name[MAX_NAME_LENGTH]; GetClientName(target, name, sizeof(name)); PerformSlay(param1, target); ShowActivity2(param1, "[SM] ", "%t", "Slayed target", "_s", name); diff --git a/plugins/rockthevote.sp b/plugins/rockthevote.sp index cb1528ac..34263d7e 100644 --- a/plugins/rockthevote.sp +++ b/plugins/rockthevote.sp @@ -210,7 +210,7 @@ AttemptRTV(client) return; } - new String:name[64]; + new String:name[MAX_NAME_LENGTH]; GetClientName(client, name, sizeof(name)); g_Votes++;