mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-29 06:07:57 +03:00
Sanitize the name with a maximum buffer size limit
This commit is contained in:
parent
5801af34bb
commit
333c452f44
5 changed files with 9 additions and 6 deletions
|
@ -2580,7 +2580,7 @@ void CL_CheckUserinfo( void ) {
|
|||
// send a reliable userinfo update if needed
|
||||
if(cvar_modifiedFlags & CVAR_USERINFO)
|
||||
{
|
||||
if (Com_SanitizeName(name->string, szSanitizedName)) {
|
||||
if (Com_SanitizeName(name->string, szSanitizedName, sizeof(szSanitizedName))) {
|
||||
Cvar_Set("name", szSanitizedName);
|
||||
}
|
||||
|
||||
|
|
|
@ -772,7 +772,7 @@ void G_ClientUserinfoChanged(gentity_t *ent, const char *u)
|
|||
|
||||
clientnum = ent - g_entities;
|
||||
|
||||
if (gi.SanitizeName(s, client->pers.netname)) {
|
||||
if (gi.SanitizeName(s, client->pers.netname, sizeof(client->pers.netname))) {
|
||||
gi.Printf("WARNING: had to sanitize the name for client %i\n", clientnum);
|
||||
}
|
||||
|
||||
|
|
|
@ -478,7 +478,7 @@ typedef struct gameImport_s {
|
|||
void (*HudDrawAlpha)(int info, float alpha);
|
||||
void (*HudDrawString)(int info, const char *string);
|
||||
void (*HudDrawFont)(int info, const char *fontName);
|
||||
qboolean (*SanitizeName)(const char *oldName, char *newName);
|
||||
qboolean (*SanitizeName)(const char *oldName, char *newName, size_t bufferSize);
|
||||
|
||||
//
|
||||
// Added in OPM
|
||||
|
|
|
@ -2372,11 +2372,14 @@ void Com_Shutdown (void) {
|
|||
|
||||
}
|
||||
|
||||
qboolean Com_SanitizeName( const char *pszOldName, char *pszNewName )
|
||||
qboolean Com_SanitizeName( const char *pszOldName, char *pszNewName, size_t bufferSize )
|
||||
{
|
||||
int i;
|
||||
qboolean bBadName = qfalse;
|
||||
const char *p = pszOldName;
|
||||
size_t maxLength;
|
||||
|
||||
maxLength = (bufferSize / sizeof(char)) - 1;
|
||||
|
||||
if( *pszOldName && *pszOldName <= ' ' )
|
||||
{
|
||||
|
@ -2389,7 +2392,7 @@ qboolean Com_SanitizeName( const char *pszOldName, char *pszNewName )
|
|||
}
|
||||
|
||||
i = 0;
|
||||
for( i = 0; *p && *p >= ' '; p++, i++ )
|
||||
for( i = 0; *p && *p >= ' ' && i < maxLength; p++, i++ )
|
||||
{
|
||||
if( *p == '~' || *p == '`' )
|
||||
{
|
||||
|
|
|
@ -1155,7 +1155,7 @@ void Com_Init( char *commandLine );
|
|||
void Com_Frame( void );
|
||||
void Com_Shutdown( void );
|
||||
|
||||
qboolean Com_SanitizeName( const char *pszOldName, char *pszNewName );
|
||||
qboolean Com_SanitizeName( const char *pszOldName, char *pszNewName, size_t bufferSize );
|
||||
const char *Com_GetArchiveFileName( const char *filename, const char *extension );
|
||||
const char *Com_GetArchiveFolder();
|
||||
void Com_WipeSavegame( const char *savename );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue