Skip to content

Commit

Permalink
Fix inconsistencies with buffer sizes for player names.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
psychonic committed Jun 4, 2015
1 parent 5139eef commit 9e0dbfc
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions plugins/admin-sql-threaded.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion plugins/basebans/ban.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion plugins/funcommands/beacon.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion plugins/funcommands/blind.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion plugins/funcommands/drug.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions plugins/funcommands/fire.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion plugins/funcommands/gravity.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions plugins/funcommands/ice.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion plugins/funcommands/noclip.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions plugins/funcommands/timebomb.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion plugins/funvotes.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions plugins/include/helpers.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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;
Expand All @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions plugins/nominations.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion plugins/playercommands/slap.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion plugins/playercommands/slay.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion plugins/rockthevote.sp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ AttemptRTV(client)
return;
}

new String:name[64];
new String:name[MAX_NAME_LENGTH];
GetClientName(client, name, sizeof(name));

g_Votes++;
Expand Down

0 comments on commit 9e0dbfc

Please sign in to comment.