Fix crashes when song paths begin with "../".
This commit is contained in:
+16
-8
@@ -443,12 +443,19 @@ static bool ImageIsLoadable( const CString &sPath )
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/* Fix up song paths. If there's a leading "./", be sure to keep it: it's
|
/* Fix up song paths. If there's a leading "./", be sure to keep it: it's
|
||||||
* a signal that the path is from the root directory, not the song directory. */
|
* a signal that the path is from the root directory, not the song directory.
|
||||||
void FixupPath( CString &path )
|
* Other than a leading "./", song paths must never contain "." or "..". */
|
||||||
|
void FixupPath( CString &path, const CString &sSongPath )
|
||||||
{
|
{
|
||||||
/* Replace backslashes with slashes in all paths. */
|
/* Replace backslashes with slashes in all paths. */
|
||||||
FixSlashesInPlace( path );
|
FixSlashesInPlace( path );
|
||||||
|
|
||||||
|
if( path.Left(3) == "../" )
|
||||||
|
{
|
||||||
|
/* The path begins with "../". Resolve it wrt. the song directory. */
|
||||||
|
path = sSongPath + "/" + path;
|
||||||
|
}
|
||||||
|
|
||||||
CollapsePath( path );
|
CollapsePath( path );
|
||||||
|
|
||||||
/* Many imported files contain erroneous whitespace before or after
|
/* Many imported files contain erroneous whitespace before or after
|
||||||
@@ -586,12 +593,13 @@ void Song::TidyUpData()
|
|||||||
|
|
||||||
CHECKPOINT_M( "Looking for images..." );
|
CHECKPOINT_M( "Looking for images..." );
|
||||||
|
|
||||||
FixupPath( m_sSongDir );
|
ASSERT_M( m_sSongDir.Left(3) != "../", m_sSongDir ); /* meaningless */
|
||||||
FixupPath( m_sMusicFile );
|
FixupPath( m_sSongDir, "" );
|
||||||
FixupPath( m_sBannerFile );
|
FixupPath( m_sMusicFile, m_sSongDir );
|
||||||
FixupPath( m_sLyricsFile );
|
FixupPath( m_sBannerFile, m_sSongDir );
|
||||||
FixupPath( m_sBackgroundFile );
|
FixupPath( m_sLyricsFile, m_sSongDir );
|
||||||
FixupPath( m_sCDTitleFile );
|
FixupPath( m_sBackgroundFile, m_sSongDir );
|
||||||
|
FixupPath( m_sCDTitleFile, m_sSongDir );
|
||||||
|
|
||||||
//
|
//
|
||||||
// First, check the file name for hints.
|
// First, check the file name for hints.
|
||||||
|
|||||||
Reference in New Issue
Block a user