From 9964af343234de0f04383eca43fb985e81fe04d6 Mon Sep 17 00:00:00 2001 From: Johannes Schultz Date: Sun, 2 Jun 2024 14:49:22 +0000 Subject: [PATCH] Merged revision(s) 20901, 20903-20904 from trunk/OpenMPT: [Fix] PSM: File header probing was stricter than actual file loader. ........ [Fix] Fuzzer: Don't return from the AFL loop if we weren't able to load a file. ........ [Fix] PSM: Header probing was still too strict. ........ git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.29@20907 56274372-70c3-4bfc-bfc3-4c3a0b034d27 --- contrib/fuzzing/fuzz.cpp | 2 +- soundlib/Load_psm.cpp | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/contrib/fuzzing/fuzz.cpp b/contrib/fuzzing/fuzz.cpp index 4a60481f7de..4e12367b30b 100644 --- a/contrib/fuzzing/fuzz.cpp +++ b/contrib/fuzzing/fuzz.cpp @@ -63,7 +63,7 @@ int main( int argc, char * argv[] ) { OpenMPT::mpt::reinit_global_random(); openmpt_module * mod = openmpt_module_create_from_memory2( fileBuffer, fileSize, nullptr, nullptr, ErrFunc, nullptr, nullptr, nullptr, nullptr); if ( mod == NULL ) - return 1; + break; // verify API contract: If the file can be loaded, header probing must be successful too. if ( openmpt_probe_file_header( OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT, fileBuffer, fileSize, fileSize, nullptr, nullptr, ErrFunc, nullptr, nullptr, nullptr ) == OPENMPT_PROBE_FILE_HEADER_RESULT_FAILURE ) diff --git a/soundlib/Load_psm.cpp b/soundlib/Load_psm.cpp index 9f0f41c730a..e746e9f6298 100644 --- a/soundlib/Load_psm.cpp +++ b/soundlib/Load_psm.cpp @@ -234,19 +234,6 @@ CSoundFile::ProbeResult CSoundFile::ProbeFileHeaderPSM(MemoryFileReader file, co { return ProbeFailure; } - PSMChunk chunkHeader; - if(!file.ReadStruct(chunkHeader)) - { - return ProbeWantMoreData; - } - if(chunkHeader.length == 0) - { - return ProbeFailure; - } - if((chunkHeader.id & 0x7F7F7F7Fu) != chunkHeader.id) // ASCII? - { - return ProbeFailure; - } MPT_UNREFERENCED_PARAMETER(pfilesize); return ProbeSuccess; }