Better bounds check from HL25 update. (#469)

This commit is contained in:
Andrey Akhmichin 2024-09-18 20:17:24 +00:00 committed by GitHub
parent f1c430ae1d
commit 9212d51088
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 18 additions and 8 deletions

View File

@ -628,6 +628,14 @@ void ClientCommand( edict_t *pEntity )
strncpy( command, pcmd, sizeof(command) - 1);
command[sizeof(command) - 1] = '\0';
// First parse the name and remove any %'s
for( char *pApersand = command; *pApersand; pApersand++ )
{
// Replace it with a space
if( *pApersand == '%' )
*pApersand = ' ';
}
// tell the user they entered an unknown command
ClientPrint( &pEntity->v, HUD_PRINTCONSOLE, UTIL_VarArgs( "Unknown command: %s\n", command ) );
}

View File

@ -764,7 +764,7 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd )
{
char tmp[128];
UTIL_StripToken( pkvd->szKeyName, tmp );
UTIL_StripToken( pkvd->szKeyName, tmp, sizeof( tmp ));
m_weaponNames[i] = ALLOC_STRING( tmp );
m_weaponCount[i] = atoi( pkvd->szValue );

View File

@ -318,7 +318,7 @@ void CMultiManager::KeyValue( KeyValueData *pkvd )
{
char tmp[128];
UTIL_StripToken( pkvd->szKeyName, tmp );
UTIL_StripToken( pkvd->szKeyName, tmp, sizeof( tmp ));
m_iTargetName[m_cTargets] = ALLOC_STRING( tmp );
m_flTargetDelay[m_cTargets] = atof( pkvd->szValue );
m_cTargets++;

View File

@ -1325,7 +1325,8 @@ void UTIL_StringToVector( float *pVector, const char *pString )
char *pstr, *pfront, tempString[128];
int j;
strcpy( tempString, pString );
strncpy( tempString, pString, sizeof( tempString ));
tempString[sizeof( tempString ) - 1] = '\0';
pstr = pfront = tempString;
for( j = 0; j < 3; j++ ) // lifted from pr_edict.c
@ -1355,7 +1356,8 @@ void UTIL_StringToIntArray( int *pVector, int count, const char *pString )
char *pstr, *pfront, tempString[128];
int j;
strcpy( tempString, pString );
strncpy( tempString, pString, sizeof( tempString ));
tempString[sizeof( tempString ) - 1] = '\0';
pstr = pfront = tempString;
for( j = 0; j < count; j++ ) // lifted from pr_edict.c
@ -1560,11 +1562,11 @@ float UTIL_DotPoints( const Vector &vecSrc, const Vector &vecCheck, const Vector
//=========================================================
// UTIL_StripToken - for redundant keynames
//=========================================================
void UTIL_StripToken( const char *pKey, char *pDest )
void UTIL_StripToken( const char *pKey, char *pDest, int nLen )
{
int i = 0;
while( pKey[i] && pKey[i] != '#' )
while( i < nLen - 1 && pKey[i] && pKey[i] != '#' )
{
pDest[i] = pKey[i];
i++;
@ -2136,7 +2138,7 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou
{
fieldNumber = ( i + startField ) % fieldCount;
pTest = &pFields[fieldNumber];
if( !stricmp( pTest->fieldName, pName ) )
if( pTest->fieldName && !stricmp( pTest->fieldName, pName ) )
{
if( !m_global || !(pTest->flags & FTYPEDESC_GLOBAL ) )
{

View File

@ -380,7 +380,7 @@ extern void UTIL_LogPrintf( const char *fmt, ... );
// Sorta like FInViewCone, but for nonmonsters.
extern float UTIL_DotPoints ( const Vector &vecSrc, const Vector &vecCheck, const Vector &vecDir );
extern void UTIL_StripToken( const char *pKey, char *pDest );// for redundant keynames
extern void UTIL_StripToken( const char *pKey, char *pDest, int nLen );// for redundant keynames
// Misc functions
extern void SetMovedir(entvars_t* pev);