server: Ensure no buffer overflows when sscanf to char buffer
Closes #878
This commit is contained in:
parent
bdb575377e
commit
e83ecdfa3c
|
|
@ -1853,11 +1853,14 @@ bool CTFPasstimeLogic::ParseSetSection( const char *pStr, SetSectionParams &s )
|
||||||
{
|
{
|
||||||
char pszStartName[64];
|
char pszStartName[64];
|
||||||
char pszEndName[64];
|
char pszEndName[64];
|
||||||
const int iScanCount = sscanf( pStr, "%i %s %s", &s.num, pszStartName, pszEndName ); // WHAT YEAR IS IT
|
const int iScanCount = sscanf( pStr, "%i %63s %63s", &s.num, pszStartName, pszEndName ); // WHAT YEAR IS IT
|
||||||
if ( iScanCount != 3 )
|
if ( iScanCount != 3 )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
pszStartName[ ARRAYSIZE(pszStartName) - 1 ] = '\0';
|
||||||
|
pszEndName[ ARRAYSIZE(pszEndName) - 1 ] = '\0';
|
||||||
|
|
||||||
s.pSectionStart = dynamic_cast<CPathTrack*>( gEntList.FindEntityByName( 0, pszStartName ) );
|
s.pSectionStart = dynamic_cast<CPathTrack*>( gEntList.FindEntityByName( 0, pszStartName ) );
|
||||||
s.pSectionEnd = dynamic_cast<CPathTrack*>( gEntList.FindEntityByName( 0, pszEndName ) );
|
s.pSectionEnd = dynamic_cast<CPathTrack*>( gEntList.FindEntityByName( 0, pszEndName ) );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5950,8 +5950,9 @@ void CTFPlayer::HandleAnimEvent( animevent_t *pEvent )
|
||||||
char szAttrName[128];
|
char szAttrName[128];
|
||||||
float flVal;
|
float flVal;
|
||||||
float flDuration;
|
float flDuration;
|
||||||
if ( sscanf( pEvent->options, "%s %f %f", szAttrName, &flVal, &flDuration ) == 3 )
|
if ( sscanf( pEvent->options, "%127s %f %f", szAttrName, &flVal, &flDuration ) == 3 )
|
||||||
{
|
{
|
||||||
|
szAttrName[ ARRAYSIZE(szAttrName) - 1 ] = '\0';
|
||||||
Assert( flDuration > 0.f );
|
Assert( flDuration > 0.f );
|
||||||
AddCustomAttribute( szAttrName, flVal, flDuration );
|
AddCustomAttribute( szAttrName, flVal, flDuration );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue