edits cleanup:

- only allow reasonable file sizes
 - only allow one Steps per edit file
 - only allow 5 edits per-song, per-profile
This commit is contained in:
Chris Danford
2004-04-23 00:26:51 +00:00
parent d3f3db2751
commit cca71d1d3f
9 changed files with 51 additions and 19 deletions
+18
View File
@@ -7,6 +7,9 @@
#include "RageLog.h"
#include "RageUtil.h"
#include "SongManager.h"
#include "RageFileManager.h"
#define MAX_EDIT_SIZE_BYTES 20*1024 // 20 KB
void SMLoader::LoadFromSMTokens(
CString sNotesType,
@@ -376,6 +379,13 @@ bool SMLoader::LoadEdit( CString sEditFilePath, ProfileSlot slot )
{
LOG->Trace( "Song::LoadEdit(%s)", sEditFilePath.c_str() );
int iBytes = FILEMAN->GetFileSizeInBytes( sEditFilePath );
if( iBytes > MAX_EDIT_SIZE_BYTES )
{
LOG->Warn( "The edit '%s' is unreasonably large. It won't be loaded.", sEditFilePath.c_str() );
return false;
}
MsdFile msd;
bool bResult = msd.ReadFile( sEditFilePath );
if( !bResult )
@@ -407,6 +417,12 @@ bool SMLoader::LoadEdit( CString sEditFilePath, ProfileSlot slot )
LOG->Warn( "The edit file '%s' required a song '%s' that isn't present.", sEditFilePath.c_str(), sSongFullTitle.c_str() );
return false;
}
if( pSong->GetNumStepsLoadedFromProfile(slot) >= MAX_EDITS_PER_SONG_PER_PLAYER )
{
LOG->Warn( "The song '%s' already has the maximum number of edits allowed for ProfileSlotP%d.", sSongFullTitle.c_str(), slot+1 );
return false;
}
}
else if( 0==stricmp(sValueName,"NOTES") )
@@ -433,6 +449,8 @@ bool SMLoader::LoadEdit( CString sEditFilePath, ProfileSlot slot )
pNewNotes->SetLoadedFromProfile( slot );
pNewNotes->SetDifficulty( DIFFICULTY_EDIT );
return true; // Only allow one Steps per edit file!
}
else
LOG->Trace( "Unexpected value named '%s'", sValueName.c_str() );