Skip to content

Commit

Permalink
[Fix] Also limit sample pre-amp to 2000 for formats where we retrieve…
Browse files Browse the repository at this point in the history
… it through other means than OpenMPT song extensions (e.g. MO3). Found with afl++ + ubsan.

[Fix] Sanitize sample length and loop points for missing external samples as well. Otherwise invalid values might be used during seeking. Found with afl++ + ubsan.

git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@22241 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Nov 19, 2024
1 parent 9d25d42 commit 3c85c60
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 0 additions & 5 deletions soundlib/Load_it.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2664,11 +2664,6 @@ bool CSoundFile::LoadExtendedSongProperties(FileReader &file, bool ignoreChannel
m_nMixLevels = MixLevels::Original;
//m_dwCreatedWithVersion
//m_dwLastSavedWithVersion
LimitMax(m_nSamplePreAmp, 2000u);
LimitMax(m_nVSTiVolume, 2000u);
LimitMax(m_nDefaultGlobalVolume, MAX_GLOBAL_VOLUME);
LimitMax(m_nDefaultRowsPerBeat, MAX_ROWS_PER_BEAT);
LimitMax(m_nDefaultRowsPerMeasure, MAX_ROWS_PER_BEAT);

return true;
}
Expand Down
4 changes: 4 additions & 0 deletions soundlib/Sndfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,8 @@ bool CSoundFile::CreateInternal(FileReader file, ModLoadingFlags loadFlags)
for(SAMPLEINDEX nSmp = 1; nSmp <= m_nSamples; nSmp++)
{
ModSample &sample = Samples[nSmp];
LimitMax(sample.nLength, MAX_SAMPLE_LENGTH);
sample.SanitizeLoops();

#ifdef MPT_EXTERNAL_SAMPLES
if(SampleHasPath(nSmp) && (loadFlags & loadSampleData))
Expand Down Expand Up @@ -671,6 +673,8 @@ bool CSoundFile::CreateInternal(FileReader file, ModLoadingFlags loadFlags)
LimitMax(m_nDefaultRowsPerBeat, MAX_ROWS_PER_BEAT);
LimitMax(m_nDefaultRowsPerMeasure, MAX_ROWS_PER_BEAT);
LimitMax(m_nDefaultGlobalVolume, MAX_GLOBAL_VOLUME);
LimitMax(m_nSamplePreAmp, 2000);
LimitMax(m_nVSTiVolume, 2000);
if(!m_tempoSwing.empty())
m_tempoSwing.resize(m_nDefaultRowsPerBeat);

Expand Down

0 comments on commit 3c85c60

Please sign in to comment.