mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Improve persona name validations
Move all server convars out of the EbisuSDK lib, the min/max name len are now parameterized. This also makes it possible to use the code on the client if ever needed.
This commit is contained in:
parent
dccb897c27
commit
6bb622314e
@ -1,5 +1,4 @@
|
||||
#include "core/stdafx.h"
|
||||
#include "tier1/cvar.h"
|
||||
#include "ebisusdk/EbisuSDK.h"
|
||||
#include "engine/server/sv_main.h"
|
||||
|
||||
@ -44,17 +43,12 @@ bool IsOriginInitialized()
|
||||
// Input : *pszName -
|
||||
// Output : true on success, false on failure
|
||||
//-----------------------------------------------------------------------------
|
||||
bool IsValidPersonaName(const char* pszName)
|
||||
bool IsValidPersonaName(const char* pszName, int nMinLen, int nMaxLen)
|
||||
{
|
||||
if (!sv_validatePersonaName->GetBool())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t len = strlen(pszName);
|
||||
|
||||
if (len < sv_minPersonaNameLength->GetInt() ||
|
||||
len > sv_maxPersonaNameLength->GetInt())
|
||||
if (len < nMinLen ||
|
||||
len > nMaxLen)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ inline bool* g_EbisuProfileInit = nullptr;
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void HEbisuSDK_Init();
|
||||
bool IsOriginInitialized();
|
||||
bool IsValidPersonaName(const char* pszName);
|
||||
bool IsValidPersonaName(const char* pszName, int nMinLen, int nMaxLen);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class VEbisuSDK : public IDetour
|
||||
|
@ -105,8 +105,24 @@ CClient* CServer::ConnectClient(CServer* pServer, user_creds_s* pChallenge)
|
||||
DevMsg(eDLL_T::SERVER, "Processing connectionless challenge for '[%s]:%i' ('%llu')\n",
|
||||
pszAddresBuffer, nPort, nNucleusID);
|
||||
|
||||
bool bValidName = false;
|
||||
|
||||
if (VALID_CHARSTAR(pszPersonaName) &&
|
||||
V_IsValidUTF8(pszPersonaName))
|
||||
{
|
||||
if (sv_validatePersonaName->GetBool() &&
|
||||
!IsValidPersonaName(pszPersonaName, sv_minPersonaNameLength->GetInt(), sv_maxPersonaNameLength->GetInt()))
|
||||
{
|
||||
bValidName = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bValidName = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Only proceed connection if the client's name is valid and UTF-8 encoded.
|
||||
if (!VALID_CHARSTAR(pszPersonaName) || !V_IsValidUTF8(pszPersonaName) || !IsValidPersonaName(pszPersonaName))
|
||||
if (!bValidName)
|
||||
{
|
||||
pServer->RejectConnection(pServer->m_Socket, &pChallenge->netAdr, "#Valve_Reject_Invalid_Name");
|
||||
if (bEnableLogging)
|
||||
|
Loading…
x
Reference in New Issue
Block a user