Skip to content

Commit

Permalink
Merged revision(s) 20412 from trunk/OpenMPT:
Browse files Browse the repository at this point in the history
[Fix] OKT: Don't reject files with non-ASCII chunk IDs. This fixes "katharsis - piano lesson.okta" which appears to have some leftover junk with unused sample data at the end of the file (https://www.un4seen.com/forum/?topic=15448.msg142562#msg142562).
........


git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.29@20415 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Mar 17, 2024
1 parent 32eae18 commit e49f726
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions soundlib/Load_okt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ struct OktIffChunk
idSBOD = MagicBE("SBOD"),
};

uint32be signature; // IFF chunk name
uint32be chunksize; // chunk size without header
uint32be signature; // IFF chunk name
uint32be chunksize; // chunk size without header
};

MPT_BINARY_STRUCT(OktIffChunk, 8)
Expand Down Expand Up @@ -279,19 +279,6 @@ CSoundFile::ProbeResult CSoundFile::ProbeFileHeaderOKT(MemoryFileReader file, co
{
return ProbeFailure;
}
OktIffChunk iffHead;
if(!file.ReadStruct(iffHead))
{
return ProbeWantMoreData;
}
if(iffHead.chunksize == 0)
{
return ProbeFailure;
}
if((iffHead.signature & 0x80808080u) != 0) // ASCII?
{
return ProbeFailure;
}
MPT_UNREFERENCED_PARAMETER(pfilesize);
return ProbeSuccess;
}
Expand All @@ -305,7 +292,6 @@ bool CSoundFile::ReadOKT(FileReader &file, ModLoadingFlags loadFlags)
return false;
}

// prepare some arrays to store offsets etc.
std::vector<FileReader> patternChunks;
std::vector<FileReader> sampleChunks;
std::vector<bool> sample7bit; // 7-/8-bit sample
Expand All @@ -322,15 +308,11 @@ bool CSoundFile::ReadOKT(FileReader &file, ModLoadingFlags loadFlags)
{
OktIffChunk iffHead;
if(!file.ReadStruct(iffHead))
{
break;
}

FileReader chunk = file.ReadChunk(iffHead.chunksize);
if(!chunk.IsValid())
{
break;
}
continue;

switch(iffHead.signature)
{
Expand Down Expand Up @@ -408,12 +390,6 @@ bool CSoundFile::ReadOKT(FileReader &file, ModLoadingFlags loadFlags)
sampleChunks.push_back(chunk);
}
break;

default:
// Non-ASCII chunk ID?
if(iffHead.signature & 0x80808080)
return false;
break;
}
}

Expand Down

0 comments on commit e49f726

Please sign in to comment.