Fix a couple possible overflows

This commit is contained in:
Glenn Maynard
2003-09-25 23:27:25 +00:00
parent ff8196712e
commit c16abcc8e8
+19 -10
View File
@@ -297,6 +297,15 @@ void SongManager::FreeSongs()
m_sGroupBannerPaths.clear(); m_sGroupBannerPaths.clear();
} }
static CString ReadLine( FILE *fp )
{
char buf[1024];
fgets( buf, sizeof(buf), fp );
CString ret( buf );
TrimRight( ret );
return ret;
}
void SongManager::ReadNoteScoresFromFile( CString fn, int c ) void SongManager::ReadNoteScoresFromFile( CString fn, int c )
@@ -376,11 +385,11 @@ void SongManager::ReadCourseScoresFromFile( CString fn, int c )
{ {
while( fp && !feof(fp) ) while( fp && !feof(fp) )
{ {
char szPath[256]; CString path=ReadLine( fp );
fscanf(fp, "%[^\n]\n", szPath);
Course* pCourse = GetCourseFromPath( szPath ); Course* pCourse = GetCourseFromPath( path );
if( pCourse == NULL ) if( pCourse == NULL )
pCourse = GetCourseFromName( szPath ); pCourse = GetCourseFromName( path );
for( int i=0; i<NUM_STEPS_TYPES; i++ ) for( int i=0; i<NUM_STEPS_TYPES; i++ )
if( !feof(fp) ) if( !feof(fp) )
@@ -437,13 +446,13 @@ void SongManager::ReadCourseRankingsFromFile( CString fn )
{ {
while( fp && !feof(fp) ) while( fp && !feof(fp) )
{ {
char szPath[256]; CString path=ReadLine( fp );
fscanf(fp, "%[^\n]\n", szPath);
Course* pCourse = GetCourseFromPath( szPath );
if( pCourse == NULL )
pCourse = GetCourseFromName( szPath );
for( int i=0; i<NUM_STEPS_TYPES; i++ ) Course* pCourse = GetCourseFromPath( path );
if( pCourse == NULL )
pCourse = GetCourseFromName( path );
for( int i=0; i<NUM_STEPS_TYPES; i++ )
for( int j=0; j<NUM_RANKING_LINES; j++ ) for( int j=0; j<NUM_RANKING_LINES; j++ )
if( !feof(fp) ) if( !feof(fp) )
{ {