From f595f5701fd21698da7fc6e744aca789d4715c11 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 21 Aug 2004 04:21:33 +0000 Subject: [PATCH] don't load unreasonably large .edit files --- stepmania/src/SongManager.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index f4737df062..8a25d026f8 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -37,6 +37,7 @@ SongManager* SONGMAN = NULL; // global and accessable from anywhere in our progr #define COURSES_DIR "Courses/" #define MAX_EDITS_PER_PROFILE 200 +#define MAX_EDIT_SIZE_BYTES 8*1024 // 8KB #define NUM_GROUP_COLORS THEME->GetMetricI("SongManager","NumGroupColors") #define GROUP_COLOR( i ) THEME->GetMetricC("SongManager",ssprintf("GroupColor%d",i+1)) @@ -1128,9 +1129,16 @@ void SongManager::LoadAllFromProfiles() for( unsigned i=0; iGetFileSizeInBytes( fn ); + if( iBytes > MAX_EDIT_SIZE_BYTES ) + { + LOG->Warn( "The file '%s' is unreasonably large. It won't be loaded.", fn.c_str() ); + continue; + } + + SMLoader::LoadEdit( fn, (ProfileSlot) s ); } }