[General]: Fix upper bound check here (#885)
This commit is contained in:
parent
b53781c0bc
commit
4aa8e8c7dd
@ -6,6 +6,21 @@ namespace Components
|
||||
{
|
||||
Dvar::Var PlayerName::sv_allowColoredNames;
|
||||
|
||||
bool PlayerName::IsBadChar(int c)
|
||||
{
|
||||
if (c == '%')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (c < 32 || c > 126)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void PlayerName::UserInfoCopy(char* buffer, const char* name, const int size)
|
||||
{
|
||||
if (!sv_allowColoredNames.get<bool>())
|
||||
@ -71,13 +86,8 @@ namespace Components
|
||||
while (i < size - 1 && dest[i] != '\0')
|
||||
{
|
||||
// Check for various illegal characters
|
||||
|
||||
if (dest[i] == '%')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (std::iscntrl(static_cast<unsigned char>(dest[i])))
|
||||
const auto c = static_cast<unsigned char>(dest[i]);
|
||||
if (IsBadChar(c))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ namespace Components
|
||||
// Message used when kicking players
|
||||
static constexpr auto INVALID_NAME_MSG = "Invalid name detected";
|
||||
|
||||
static bool IsBadChar(int c);
|
||||
|
||||
static char* CleanStrStub(char* string);
|
||||
static void ClientCleanName();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user