[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;
|
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)
|
void PlayerName::UserInfoCopy(char* buffer, const char* name, const int size)
|
||||||
{
|
{
|
||||||
if (!sv_allowColoredNames.get<bool>())
|
if (!sv_allowColoredNames.get<bool>())
|
||||||
@ -71,13 +86,8 @@ namespace Components
|
|||||||
while (i < size - 1 && dest[i] != '\0')
|
while (i < size - 1 && dest[i] != '\0')
|
||||||
{
|
{
|
||||||
// Check for various illegal characters
|
// Check for various illegal characters
|
||||||
|
const auto c = static_cast<unsigned char>(dest[i]);
|
||||||
if (dest[i] == '%')
|
if (IsBadChar(c))
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (std::iscntrl(static_cast<unsigned char>(dest[i])))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ namespace Components
|
|||||||
// Message used when kicking players
|
// Message used when kicking players
|
||||||
static constexpr auto INVALID_NAME_MSG = "Invalid name detected";
|
static constexpr auto INVALID_NAME_MSG = "Invalid name detected";
|
||||||
|
|
||||||
|
static bool IsBadChar(int c);
|
||||||
|
|
||||||
static char* CleanStrStub(char* string);
|
static char* CleanStrStub(char* string);
|
||||||
static void ClientCleanName();
|
static void ClientCleanName();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user