You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
(10) |
Sep
|
Oct
|
Nov
|
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(1) |
Feb
(2) |
Mar
(3) |
Apr
(2) |
May
(10) |
Jun
(2) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
2008 |
Jan
(6) |
Feb
(4) |
Mar
(5) |
Apr
(2) |
May
(1) |
Jun
(1) |
Jul
(4) |
Aug
(6) |
Sep
(2) |
Oct
(9) |
Nov
(1) |
Dec
(4) |
2009 |
Jan
(9) |
Feb
(2) |
Mar
(2) |
Apr
(2) |
May
(6) |
Jun
(18) |
Jul
(33) |
Aug
(39) |
Sep
(33) |
Oct
(24) |
Nov
(23) |
Dec
(22) |
2010 |
Jan
(29) |
Feb
(32) |
Mar
(51) |
Apr
(17) |
May
(31) |
Jun
(21) |
Jul
(32) |
Aug
(28) |
Sep
(35) |
Oct
(27) |
Nov
(11) |
Dec
(13) |
2011 |
Jan
(14) |
Feb
(13) |
Mar
(27) |
Apr
(27) |
May
(28) |
Jun
(20) |
Jul
(43) |
Aug
(52) |
Sep
(66) |
Oct
(61) |
Nov
(11) |
Dec
(8) |
2012 |
Jan
(20) |
Feb
(30) |
Mar
(38) |
Apr
(21) |
May
(33) |
Jun
(21) |
Jul
(25) |
Aug
(9) |
Sep
(24) |
Oct
(42) |
Nov
(27) |
Dec
(41) |
2013 |
Jan
(20) |
Feb
(35) |
Mar
(156) |
Apr
(298) |
May
(258) |
Jun
(201) |
Jul
(105) |
Aug
(60) |
Sep
(193) |
Oct
(245) |
Nov
(280) |
Dec
(194) |
2014 |
Jan
(63) |
Feb
(202) |
Mar
(200) |
Apr
(23) |
May
(53) |
Jun
(105) |
Jul
(18) |
Aug
(26) |
Sep
(110) |
Oct
(187) |
Nov
(97) |
Dec
(74) |
2015 |
Jan
(45) |
Feb
(55) |
Mar
(116) |
Apr
(116) |
May
(193) |
Jun
(164) |
Jul
(50) |
Aug
(111) |
Sep
(98) |
Oct
(71) |
Nov
(103) |
Dec
(63) |
2016 |
Jan
(33) |
Feb
(101) |
Mar
(182) |
Apr
(139) |
May
(140) |
Jun
(103) |
Jul
(165) |
Aug
(286) |
Sep
(208) |
Oct
(127) |
Nov
(97) |
Dec
(54) |
2017 |
Jan
(64) |
Feb
(335) |
Mar
(202) |
Apr
(212) |
May
(139) |
Jun
(127) |
Jul
(294) |
Aug
(154) |
Sep
(170) |
Oct
(152) |
Nov
(156) |
Dec
(62) |
2018 |
Jan
(168) |
Feb
(237) |
Mar
(196) |
Apr
(174) |
May
(174) |
Jun
(161) |
Jul
(127) |
Aug
(88) |
Sep
(149) |
Oct
(66) |
Nov
(52) |
Dec
(135) |
2019 |
Jan
(146) |
Feb
(126) |
Mar
(104) |
Apr
(58) |
May
(60) |
Jun
(28) |
Jul
(197) |
Aug
(129) |
Sep
(141) |
Oct
(148) |
Nov
(63) |
Dec
(100) |
2020 |
Jan
(74) |
Feb
(37) |
Mar
(59) |
Apr
(154) |
May
(194) |
Jun
(133) |
Jul
(313) |
Aug
(197) |
Sep
(49) |
Oct
(162) |
Nov
(143) |
Dec
(57) |
2021 |
Jan
(120) |
Feb
(107) |
Mar
(314) |
Apr
(157) |
May
(524) |
Jun
(169) |
Jul
(72) |
Aug
(133) |
Sep
(135) |
Oct
(146) |
Nov
(198) |
Dec
(325) |
2022 |
Jan
(409) |
Feb
(249) |
Mar
(138) |
Apr
(95) |
May
(102) |
Jun
(221) |
Jul
(66) |
Aug
(120) |
Sep
(192) |
Oct
(131) |
Nov
(53) |
Dec
(171) |
2023 |
Jan
(357) |
Feb
(82) |
Mar
(168) |
Apr
(218) |
May
(196) |
Jun
(86) |
Jul
(115) |
Aug
(49) |
Sep
(190) |
Oct
(102) |
Nov
(45) |
Dec
(76) |
2024 |
Jan
(86) |
Feb
(50) |
Mar
(324) |
Apr
(209) |
May
(197) |
Jun
(232) |
Jul
(194) |
Aug
(247) |
Sep
(219) |
Oct
(266) |
Nov
(328) |
Dec
(304) |
2025 |
Jan
(191) |
Feb
(115) |
Mar
(137) |
Apr
(32) |
May
(126) |
Jun
(403) |
Jul
(213) |
Aug
(184) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <sv...@op...> - 2024-05-11 21:35:48
|
Author: sagamusix Date: Sat May 11 23:35:36 2024 New Revision: 20780 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20780 Log: Merged revision(s) 20736 from trunk/OpenMPT: [Imp] STK: Allow romantic.stk to load, which has a sample longer than 74KB. [Imp] STK: Also allow files to load that have garbage in the song title, but whose sample names are properly null-terminated non-empty ASCII strings. Fixes STK.Sharks-NewIntro. ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/soundlib/Load_mod.cpp Modified: branches/OpenMPT-1.31/soundlib/Load_mod.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Load_mod.cpp Sat May 11 23:19:34 2024 (r20779) +++ branches/OpenMPT-1.31/soundlib/Load_mod.cpp Sat May 11 23:35:36 2024 (r20780) @@ -1382,7 +1382,7 @@ // Check if a name string is valid (i.e. doesn't contain binary garbage data) -static uint32 CountInvalidChars(const mpt::span<const char> name) +static uint32 CountInvalidChars(const mpt::span<const char> name) noexcept { uint32 invalidChars = 0; for(int8 c : name) // char can be signed or unsigned @@ -1395,6 +1395,34 @@ } +enum class NameClassification +{ + Empty, + ValidASCII, + Invalid, +}; + +// Check if a name is a valid null-terminated ASCII string with no garbage after the null terminator, or if it's empty +static NameClassification ClassifyName(const mpt::span<const char> name) noexcept +{ + bool foundNull = false, foundNormal = false; + for(auto c : name) + { + if(c > 0 && c < ' ') + return NameClassification::Invalid; + if(c == 0) + foundNull = true; + else if(foundNull) + return NameClassification::Invalid; + else + foundNormal = true; + } + if(!foundNull) + return NameClassification::Invalid; + return foundNormal ? NameClassification::ValidASCII : NameClassification::Empty; +} + + // We'll have to do some heuristic checks to find out whether this is an old Ultimate Soundtracker module // or if it was made with the newer Soundtracker versions. // Thanks for Fraggie for this information! (https://www.un4seen.com/forum/?topic=14471.msg100829#msg100829) @@ -1433,7 +1461,8 @@ SmpLength totalSampleLen = 0; uint8 allVolumes = 0; - uint8 diskNameCount = 0; + uint8 validNameCount = 0; + bool invalidNames = false; for(SAMPLEINDEX smp = 0; smp < 15; smp++) { @@ -1444,13 +1473,16 @@ // schmokk.mod has a non-zero value here but it should not be treated as finetune if(sampleHeader.finetune != 0) invalidChars += 16; - if(sampleHeader.HasDiskName()) - diskNameCount++; + if(const auto nameType = ClassifyName(sampleHeader.name); nameType == NameClassification::ValidASCII) + validNameCount++; + else if(nameType == NameClassification::Invalid) + invalidNames = true; // Sanity checks - invalid character count adjusted for ata.mod (MD5 937b79b54026fa73a1a4d3597c26eace, SHA1 3322ca62258adb9e0ae8e9afe6e0c29d39add874) + // Sample length adjusted for romantic.stk which has a (valid) sample of length 72222 if(invalidChars > 48 || sampleHeader.volume > 64 - || sampleHeader.length > 32768) + || sampleHeader.length > 37000) { return false; } @@ -1459,8 +1491,8 @@ allVolumes |= sampleHeader.volume; } - // scramble_2.mod has a lot of garbage in the song title, but it has lots of sample names starting with st-01, so we consider those to be more important than the garbage bytes. - if(invalidCharsInTitle > 5 && diskNameCount < 4) + // scramble_2.mod has a lot of garbage in the song title, but it has lots of properly-formatted sample names, so we consider those to be more important than the garbage bytes. + if(invalidCharsInTitle > 5 && (validNameCount < 4 || invalidNames)) { return false; } |
From: <sv...@op...> - 2024-05-11 21:19:41
|
Author: sagamusix Date: Sat May 11 23:19:34 2024 New Revision: 20779 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20779 Log: Merged revision(s) 20776-20778 from branches/OpenMPT-1.29: [Fix] Compile fix for fuzzer builds. ........ [Fix] Fix fuzzer compilation. ........ Modified: branches/OpenMPT-1.28/ (props changed) branches/OpenMPT-1.28/contrib/fuzzing/fuzz.cpp Modified: branches/OpenMPT-1.28/contrib/fuzzing/fuzz.cpp ============================================================================== --- branches/OpenMPT-1.28/contrib/fuzzing/fuzz.cpp Sat May 11 23:19:02 2024 (r20778) +++ branches/OpenMPT-1.28/contrib/fuzzing/fuzz.cpp Sat May 11 23:19:34 2024 (r20779) @@ -16,7 +16,10 @@ #include <libopenmpt/libopenmpt.h> -#include "../../common/mptRandom.h" +namespace OpenMPT::mpt +{ + void reinit_global_random(); +} #define BUFFERSIZE 450 // shouldn't match OpenMPT's internal mix buffer size (512) #define SAMPLERATE 22050 |
From: <sv...@op...> - 2024-05-11 21:19:13
|
Author: sagamusix Date: Sat May 11 23:19:02 2024 New Revision: 20778 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20778 Log: [Fix] Fix fuzzer compilation. Modified: branches/OpenMPT-1.29/contrib/fuzzing/fuzz.cpp Modified: branches/OpenMPT-1.29/contrib/fuzzing/fuzz.cpp ============================================================================== --- branches/OpenMPT-1.29/contrib/fuzzing/fuzz.cpp Sat May 11 23:14:16 2024 (r20777) +++ branches/OpenMPT-1.29/contrib/fuzzing/fuzz.cpp Sat May 11 23:19:02 2024 (r20778) @@ -16,7 +16,10 @@ #include <libopenmpt/libopenmpt.h> -#include "../../common/mptRandom.h" +namespace OpenMPT::mpt +{ + void reinit_global_random(); +} #define BUFFERSIZE 450 // shouldn't match OpenMPT's internal mix buffer size (512) #define SAMPLERATE 22050 |
From: <sv...@op...> - 2024-05-11 21:14:28
|
Author: sagamusix Date: Sat May 11 23:14:16 2024 New Revision: 20777 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20777 Log: [Fix] Compile fix for fuzzer builds. Modified: branches/OpenMPT-1.28/common/mptRandom.h Modified: branches/OpenMPT-1.28/common/mptRandom.h ============================================================================== --- branches/OpenMPT-1.28/common/mptRandom.h Sat May 11 23:13:51 2024 (r20776) +++ branches/OpenMPT-1.28/common/mptRandom.h Sat May 11 23:14:16 2024 (r20777) @@ -12,6 +12,7 @@ #include "BuildSettings.h" +#include "mptBaseTypes.h" #include "mptMutex.h" #include <limits> |
From: <sv...@op...> - 2024-05-11 21:14:03
|
Author: sagamusix Date: Sat May 11 23:13:51 2024 New Revision: 20776 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20776 Log: [Fix] Compile fix for fuzzer builds. Modified: branches/OpenMPT-1.29/common/mptRandom.h Modified: branches/OpenMPT-1.29/common/mptRandom.h ============================================================================== --- branches/OpenMPT-1.29/common/mptRandom.h Sat May 11 23:04:52 2024 (r20775) +++ branches/OpenMPT-1.29/common/mptRandom.h Sat May 11 23:13:51 2024 (r20776) @@ -12,6 +12,7 @@ #include "BuildSettings.h" +#include "mptBaseTypes.h" #include "mptMutex.h" #include <limits> |
From: <sv...@op...> - 2024-05-11 21:05:03
|
Author: sagamusix Date: Sat May 11 23:04:52 2024 New Revision: 20775 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20775 Log: Merged revision(s) 20702 from trunk/OpenMPT: [Mod] MDL: Command 9 is not Set Envelope Position, it select a different envelope instead. As we only have one envelope per type per instrument, instead do the only thing we can do for now: Assume that the instrument envelope was disabled and enable it. ........ Modified: branches/OpenMPT-1.28/ (props changed) branches/OpenMPT-1.28/soundlib/Load_mdl.cpp Modified: branches/OpenMPT-1.28/soundlib/Load_mdl.cpp ============================================================================== --- branches/OpenMPT-1.28/soundlib/Load_mdl.cpp Sat May 11 23:04:31 2024 (r20774) +++ branches/OpenMPT-1.28/soundlib/Load_mdl.cpp Sat May 11 23:04:52 2024 (r20775) @@ -169,7 +169,7 @@ /* Either column */ /* 7 */ CMD_TEMPO, /* 8 */ CMD_PANNING8, - /* 9 */ CMD_SETENVPOSITION, + /* 9 */ CMD_S3MCMDEX, /* A */ CMD_NONE, /* B */ CMD_POSITIONJUMP, /* C */ CMD_GLOBALVOLUME, @@ -206,6 +206,16 @@ case 0x08: // Panning param = (param & 0x7F) * 2u; break; + case 0x09: // Set Envelope (we can only have one envelope per type...) + if(param < 0x40) + param = 0x78; // Enable the one volume envelope we have + else if (param < 0x80) + param = 0x7A; // Enable the one panning envelope we have + else if(param < 0xC0) + param = 0x7C; // Enable the one pitch envelope we have + else + cmd = CMD_NONE; + break; case 0x0C: // Global volume param = (param + 1) / 2u; break; |
From: <sv...@op...> - 2024-05-11 21:04:43
|
Author: sagamusix Date: Sat May 11 23:04:31 2024 New Revision: 20774 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20774 Log: Merged revision(s) 20702 from trunk/OpenMPT: [Mod] MDL: Command 9 is not Set Envelope Position, it select a different envelope instead. As we only have one envelope per type per instrument, instead do the only thing we can do for now: Assume that the instrument envelope was disabled and enable it. ........ Modified: branches/OpenMPT-1.29/ (props changed) branches/OpenMPT-1.29/soundlib/Load_mdl.cpp Modified: branches/OpenMPT-1.29/soundlib/Load_mdl.cpp ============================================================================== --- branches/OpenMPT-1.29/soundlib/Load_mdl.cpp Sat May 11 23:04:10 2024 (r20773) +++ branches/OpenMPT-1.29/soundlib/Load_mdl.cpp Sat May 11 23:04:31 2024 (r20774) @@ -169,7 +169,7 @@ /* Either column */ /* 7 */ CMD_TEMPO, /* 8 */ CMD_PANNING8, - /* 9 */ CMD_SETENVPOSITION, + /* 9 */ CMD_S3MCMDEX, /* A */ CMD_NONE, /* B */ CMD_POSITIONJUMP, /* C */ CMD_GLOBALVOLUME, @@ -206,6 +206,16 @@ case 0x08: // Panning param = (param & 0x7F) * 2u; break; + case 0x09: // Set Envelope (we can only have one envelope per type...) + if(param < 0x40) + param = 0x78; // Enable the one volume envelope we have + else if (param < 0x80) + param = 0x7A; // Enable the one panning envelope we have + else if(param < 0xC0) + param = 0x7C; // Enable the one pitch envelope we have + else + cmd = CMD_NONE; + break; case 0x0C: // Global volume param = (param + 1) / 2u; break; |
From: <sv...@op...> - 2024-05-11 21:04:17
|
Author: sagamusix Date: Sat May 11 23:04:10 2024 New Revision: 20773 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20773 Log: Merged revision(s) 20702 from trunk/OpenMPT: [Mod] MDL: Command 9 is not Set Envelope Position, it select a different envelope instead. As we only have one envelope per type per instrument, instead do the only thing we can do for now: Assume that the instrument envelope was disabled and enable it. ........ Modified: branches/OpenMPT-1.30/ (props changed) branches/OpenMPT-1.30/soundlib/Load_mdl.cpp Modified: branches/OpenMPT-1.30/soundlib/Load_mdl.cpp ============================================================================== --- branches/OpenMPT-1.30/soundlib/Load_mdl.cpp Sat May 11 23:01:58 2024 (r20772) +++ branches/OpenMPT-1.30/soundlib/Load_mdl.cpp Sat May 11 23:04:10 2024 (r20773) @@ -168,7 +168,7 @@ /* Either column */ /* 7 */ CMD_TEMPO, /* 8 */ CMD_PANNING8, - /* 9 */ CMD_SETENVPOSITION, + /* 9 */ CMD_S3MCMDEX, /* A */ CMD_NONE, /* B */ CMD_POSITIONJUMP, /* C */ CMD_GLOBALVOLUME, @@ -205,6 +205,16 @@ case 0x08: // Panning param = (param & 0x7F) * 2u; break; + case 0x09: // Set Envelope (we can only have one envelope per type...) + if(param < 0x40) + param = 0x78; // Enable the one volume envelope we have + else if (param < 0x80) + param = 0x7A; // Enable the one panning envelope we have + else if(param < 0xC0) + param = 0x7C; // Enable the one pitch envelope we have + else + cmd = CMD_NONE; + break; case 0x0C: // Global volume param = (param + 1) / 2u; break; |
From: <sv...@op...> - 2024-05-11 21:02:08
|
Author: sagamusix Date: Sat May 11 23:01:58 2024 New Revision: 20772 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20772 Log: Merged revision(s) 20766-20769 from branches/OpenMPT-1.30: Merged revision(s) 20651 from trunk/OpenMPT: [Var] Fuzzing: AFL_HARDEN and ASan are not compatible in v4.10c. ........ Merged revision(s) 20695-20696 from trunk/OpenMPT: [Imp] Enable host-specific performance optimizations in afl++. ........ [Var] Update fuzzer dictionary. ........ ........ Merged revision(s) 20756 from branches/OpenMPT-1.31: Merged revision(s) 20749-20750, 20755 from trunk/OpenMPT: [Mod] Reduce static variable usage in fuzzer program to eventually allow using __AFL_LOOP. ........ [Imp] mptRandom: Add reinit_global_random() function for fuzzer builds to allow deterministic consecutive fuzzer runs in the same process. ........ [Imp] Speed up fuzzing by using persistent mode and shared memory file input. Note: afl++ will report a stability of about 99.x%. According to its debug output, the unstable edges are in WavesReverb and I3DL2Reverb implementations, however the unstable edges that it finds don't make any sense. As a tiny bit of instability in these parts of the code should not hurt overall code coverage, we trade this for the significant gains in speed that persistent mode gives us. ........ ........ ........ Added: branches/OpenMPT-1.28/contrib/fuzzing/fuzz.cpp - copied unchanged from r20769, branches/OpenMPT-1.30/contrib/fuzzing/fuzz.cpp Deleted: branches/OpenMPT-1.28/contrib/fuzzing/fuzz.c Modified: branches/OpenMPT-1.28/ (props changed) branches/OpenMPT-1.28/Makefile branches/OpenMPT-1.28/common/mptRandom.cpp branches/OpenMPT-1.28/common/mptRandom.h branches/OpenMPT-1.28/contrib/fuzzing/all_formats.dict branches/OpenMPT-1.28/contrib/fuzzing/build.sh branches/OpenMPT-1.28/contrib/fuzzing/get-afl.sh Modified: branches/OpenMPT-1.28/Makefile ============================================================================== --- branches/OpenMPT-1.28/Makefile Sat May 11 23:01:40 2024 (r20771) +++ branches/OpenMPT-1.28/Makefile Sat May 11 23:01:58 2024 (r20772) @@ -1407,10 +1407,10 @@ $(SILENT)$(LINK.cc) $(BIN_LDFLAGS) $(LDFLAGS_RPATH) $(LDFLAGS_LIBOPENMPT) $(LDFLAGS_OPENMPT123) $(OPENMPT123_OBJECTS) $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) $(LDLIBS_OPENMPT123) -o $@ endif -contrib/fuzzing/fuzz.o: contrib/fuzzing/fuzz.c - $(INFO) [CC] $< - $(VERYSILENT)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -M -MT$@ $< > $*.d - $(SILENT)$(COMPILE.c) $(OUTPUT_OPTION) $< +contrib/fuzzing/fuzz.o: contrib/fuzzing/fuzz.cpp + $(INFO) [CXX] $< + $(VERYSILENT)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -M -MT$@ $< > $*.d + $(SILENT)$(COMPILE.cc) $(OUTPUT_OPTION) $< bin/fuzz$(EXESUFFIX): contrib/fuzzing/fuzz.o $(OBJECTS_LIBOPENMPT) $(OUTPUT_LIBOPENMPT) $(INFO) [LD] $@ $(SILENT)$(LINK.cc) $(LDFLAGS_LIBOPENMPT) contrib/fuzzing/fuzz.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) -o $@ Modified: branches/OpenMPT-1.28/common/mptRandom.cpp ============================================================================== --- branches/OpenMPT-1.28/common/mptRandom.cpp Sat May 11 23:01:40 2024 (r20771) +++ branches/OpenMPT-1.28/common/mptRandom.cpp Sat May 11 23:01:58 2024 (r20772) @@ -322,6 +322,16 @@ return g_global_prng; } +#ifdef MPT_BUILD_FUZZER +void reinit_global_random() +{ + global_prng().~thread_safe_prng<mpt::default_prng>(); + global_random_device().~random_device(); + new(&global_random_device()) mpt::random_device{}; + new(&global_prng()) thread_safe_prng<mpt::default_prng>{global_random_device()}; +} +#endif // MPT_BUILD_FUZZER + #endif // MODPLUG_TRACKER && !MPT_BUILD_WINESUPPORT Modified: branches/OpenMPT-1.28/common/mptRandom.h ============================================================================== --- branches/OpenMPT-1.28/common/mptRandom.h Sat May 11 23:01:40 2024 (r20771) +++ branches/OpenMPT-1.28/common/mptRandom.h Sat May 11 23:01:58 2024 (r20772) @@ -618,6 +618,10 @@ mpt::random_device & global_random_device(); mpt::thread_safe_prng<mpt::default_prng> & global_prng(); +#ifdef MPT_BUILD_FUZZER +void reinit_global_random(); +#endif // MPT_BUILD_FUZZER + #if defined(MODPLUG_TRACKER) && !defined(MPT_BUILD_WINESUPPORT) void set_global_random_device(mpt::random_device *rd); void set_global_prng(mpt::thread_safe_prng<mpt::default_prng> *rng); Modified: branches/OpenMPT-1.28/contrib/fuzzing/all_formats.dict ============================================================================== --- branches/OpenMPT-1.28/contrib/fuzzing/all_formats.dict Sat May 11 23:01:40 2024 (r20771) +++ branches/OpenMPT-1.28/contrib/fuzzing/all_formats.dict Sat May 11 23:01:58 2024 (r20772) @@ -5,7 +5,7 @@ amf="AMF\x0A" ams="Extreme" -ams="AMShdr\x1A\x02\x02" +ams="AMShdr\x1A\x00\x02\x02" #dbm="DBM0" dbm="NAME" @@ -45,7 +45,7 @@ far="\x0D\x0A\x1A" gdm="GDM\xFE" -gdm="GMFS" +gdm="\x0D\x0A\x1AGMFS\x01\x00" imf="IM10" imf="IS10" @@ -198,7 +198,7 @@ psm16="PPAT" ptm="PTMF" -ptm="\x1A\x03\x02" +ptm="\x1A\x03\x02\x00" s3m="SCRM" #s3m="SCRS" Modified: branches/OpenMPT-1.28/contrib/fuzzing/build.sh ============================================================================== --- branches/OpenMPT-1.28/contrib/fuzzing/build.sh Sat May 11 23:01:40 2024 (r20771) +++ branches/OpenMPT-1.28/contrib/fuzzing/build.sh Sat May 11 23:01:58 2024 (r20772) @@ -1,4 +1,4 @@ #!/usr/bin/env bash cd "${0%/*}" cd ../.. -AFL_HARDEN=1 CONFIG=afl make clean all EXAMPLES=0 TEST=0 OPENMPT123=0 NO_VORBIS=1 NO_VORBISFILE=1 NO_MPG123=1 CHECKED_ADDRESS=1 +AFL_USE_ASAN=1 CONFIG=afl make clean all EXAMPLES=0 TEST=0 OPENMPT123=0 NO_VORBIS=1 NO_VORBISFILE=1 NO_MPG123=1 CHECKED_ADDRESS=1 Copied: branches/OpenMPT-1.28/contrib/fuzzing/fuzz.cpp (from r20769, branches/OpenMPT-1.30/contrib/fuzzing/fuzz.cpp) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/OpenMPT-1.28/contrib/fuzzing/fuzz.cpp Sat May 11 23:01:58 2024 (r20772, copy of r20769, branches/OpenMPT-1.30/contrib/fuzzing/fuzz.cpp) @@ -0,0 +1,88 @@ +/* + * fuzz.cpp + * -------- + * Purpose: Tiny libopenmpt user to be used by fuzzing tools + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#include <memory> +#include <cstdint> +#include <cstdlib> + +#include <cerrno> +#include <unistd.h> + +#include <libopenmpt/libopenmpt.h> + +#include "../../common/mptRandom.h" + +#define BUFFERSIZE 450 // shouldn't match OpenMPT's internal mix buffer size (512) +#define SAMPLERATE 22050 + +static int16_t buffer[BUFFERSIZE]; + +static int ErrFunc (int error, void *) +{ + switch (error) + { + case OPENMPT_ERROR_INVALID_ARGUMENT: + case OPENMPT_ERROR_OUT_OF_RANGE: + case OPENMPT_ERROR_LENGTH: + case OPENMPT_ERROR_DOMAIN: + case OPENMPT_ERROR_LOGIC: + case OPENMPT_ERROR_UNDERFLOW: + case OPENMPT_ERROR_OVERFLOW: + case OPENMPT_ERROR_RANGE: + case OPENMPT_ERROR_RUNTIME: + case OPENMPT_ERROR_EXCEPTION: + std::abort(); + default: + return OPENMPT_ERROR_FUNC_RESULT_NONE; + } +} + +__AFL_FUZZ_INIT(); + +int main( int argc, char * argv[] ) { + (void)argc; + (void)argv; + openmpt_module_create_from_memory2( buffer, BUFFERSIZE, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr ); +#ifdef __AFL_HAVE_MANUAL_CONTROL + __AFL_INIT(); +#endif + + unsigned char *fileBuffer = __AFL_FUZZ_TESTCASE_BUF; // must be after __AFL_INIT and before __AFL_LOOP! + + while (__AFL_LOOP(10000)) { + int fileSize = __AFL_FUZZ_TESTCASE_LEN; + 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; + + // 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 ) + std::abort(); + + openmpt_module_ctl_set( mod, "render.resampler.emulate_amiga", (openmpt_module_get_num_orders( mod ) & 1) ? "0" : "1" ); + // render about a second of the module for fuzzing the actual mix routines + for(int i = 0; i < 50; i++) { + size_t count = openmpt_module_read_mono( mod, SAMPLERATE, BUFFERSIZE, buffer ); + if ( count == 0 ) { + break; + } + } + openmpt_module_set_position_seconds( mod, 1.0 ); + openmpt_module_read_mono( mod, SAMPLERATE, BUFFERSIZE, buffer ); + openmpt_module_set_position_order_row( mod, 3, 16 ); + openmpt_module_read_mono( mod, SAMPLERATE, BUFFERSIZE, buffer ); + + // fuzz string-related stuff + openmpt_free_string ( openmpt_module_get_metadata( mod, "date" ) ); + openmpt_free_string ( openmpt_module_get_metadata( mod, "message" ) ); + openmpt_module_destroy( mod ); + } + return 0; +} Modified: branches/OpenMPT-1.28/contrib/fuzzing/get-afl.sh ============================================================================== --- branches/OpenMPT-1.28/contrib/fuzzing/get-afl.sh Sat May 11 23:01:40 2024 (r20771) +++ branches/OpenMPT-1.28/contrib/fuzzing/get-afl.sh Sat May 11 23:01:58 2024 (r20772) @@ -12,7 +12,7 @@ tar -xzvf $AFL_FILENAME rm $AFL_FILENAME cd AFLplusplus-* -make source-only || exit +make PERFORMANCE=1 source-only || exit cd .. rm -rf afl mv AFLplusplus-* afl \ No newline at end of file |
From: <sv...@op...> - 2024-05-11 21:01:52
|
Author: sagamusix Date: Sat May 11 23:01:40 2024 New Revision: 20771 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20771 Log: Merged revision(s) 20766-20769 from branches/OpenMPT-1.30: Merged revision(s) 20651 from trunk/OpenMPT: [Var] Fuzzing: AFL_HARDEN and ASan are not compatible in v4.10c. ........ Merged revision(s) 20695-20696 from trunk/OpenMPT: [Imp] Enable host-specific performance optimizations in afl++. ........ [Var] Update fuzzer dictionary. ........ ........ Merged revision(s) 20756 from branches/OpenMPT-1.31: Merged revision(s) 20749-20750, 20755 from trunk/OpenMPT: [Mod] Reduce static variable usage in fuzzer program to eventually allow using __AFL_LOOP. ........ [Imp] mptRandom: Add reinit_global_random() function for fuzzer builds to allow deterministic consecutive fuzzer runs in the same process. ........ [Imp] Speed up fuzzing by using persistent mode and shared memory file input. Note: afl++ will report a stability of about 99.x%. According to its debug output, the unstable edges are in WavesReverb and I3DL2Reverb implementations, however the unstable edges that it finds don't make any sense. As a tiny bit of instability in these parts of the code should not hurt overall code coverage, we trade this for the significant gains in speed that persistent mode gives us. ........ ........ ........ Added: branches/OpenMPT-1.29/contrib/fuzzing/fuzz.cpp - copied unchanged from r20769, branches/OpenMPT-1.30/contrib/fuzzing/fuzz.cpp Deleted: branches/OpenMPT-1.29/contrib/fuzzing/fuzz.c Modified: branches/OpenMPT-1.29/ (props changed) branches/OpenMPT-1.29/Makefile branches/OpenMPT-1.29/common/mptRandom.cpp branches/OpenMPT-1.29/common/mptRandom.h branches/OpenMPT-1.29/contrib/fuzzing/all_formats.dict branches/OpenMPT-1.29/contrib/fuzzing/build.sh branches/OpenMPT-1.29/contrib/fuzzing/get-afl.sh Modified: branches/OpenMPT-1.29/Makefile ============================================================================== --- branches/OpenMPT-1.29/Makefile Sat May 11 22:27:18 2024 (r20770) +++ branches/OpenMPT-1.29/Makefile Sat May 11 23:01:40 2024 (r20771) @@ -1494,10 +1494,10 @@ $(SILENT)$(LINK.cc) $(BIN_LDFLAGS) $(LDFLAGS_RPATH) $(LDFLAGS_LIBOPENMPT) $(LDFLAGS_OPENMPT123) $(OPENMPT123_OBJECTS) $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) $(LDLIBS_OPENMPT123) -o $@ endif -contrib/fuzzing/fuzz.o: contrib/fuzzing/fuzz.c - $(INFO) [CC] $< - $(VERYSILENT)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -M -MT$@ $< > $*.d - $(SILENT)$(COMPILE.c) $(OUTPUT_OPTION) $< +contrib/fuzzing/fuzz.o: contrib/fuzzing/fuzz.cpp + $(INFO) [CXX] $< + $(VERYSILENT)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -M -MT$@ $< > $*.d + $(SILENT)$(COMPILE.cc) $(OUTPUT_OPTION) $< bin/fuzz$(EXESUFFIX): contrib/fuzzing/fuzz.o $(OBJECTS_LIBOPENMPT) $(OUTPUT_LIBOPENMPT) $(INFO) [LD] $@ $(SILENT)$(LINK.cc) $(LDFLAGS_LIBOPENMPT) contrib/fuzzing/fuzz.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) -o $@ Modified: branches/OpenMPT-1.29/common/mptRandom.cpp ============================================================================== --- branches/OpenMPT-1.29/common/mptRandom.cpp Sat May 11 22:27:18 2024 (r20770) +++ branches/OpenMPT-1.29/common/mptRandom.cpp Sat May 11 23:01:40 2024 (r20771) @@ -335,6 +335,16 @@ return g_global_prng; } +#ifdef MPT_BUILD_FUZZER +void reinit_global_random() +{ + global_prng().~thread_safe_prng<mpt::default_prng>(); + global_random_device().~random_device(); + new(&global_random_device()) mpt::random_device{}; + new(&global_prng()) thread_safe_prng<mpt::default_prng>{global_random_device()}; +} +#endif // MPT_BUILD_FUZZER + #endif // MODPLUG_TRACKER && !MPT_BUILD_WINESUPPORT Modified: branches/OpenMPT-1.29/common/mptRandom.h ============================================================================== --- branches/OpenMPT-1.29/common/mptRandom.h Sat May 11 22:27:18 2024 (r20770) +++ branches/OpenMPT-1.29/common/mptRandom.h Sat May 11 23:01:40 2024 (r20771) @@ -721,6 +721,10 @@ mpt::random_device & global_random_device(); mpt::thread_safe_prng<mpt::default_prng> & global_prng(); +#ifdef MPT_BUILD_FUZZER +void reinit_global_random(); +#endif // MPT_BUILD_FUZZER + #if defined(MODPLUG_TRACKER) && !defined(MPT_BUILD_WINESUPPORT) void set_global_random_device(mpt::random_device *rd); void set_global_prng(mpt::thread_safe_prng<mpt::default_prng> *rng); Modified: branches/OpenMPT-1.29/contrib/fuzzing/all_formats.dict ============================================================================== --- branches/OpenMPT-1.29/contrib/fuzzing/all_formats.dict Sat May 11 22:27:18 2024 (r20770) +++ branches/OpenMPT-1.29/contrib/fuzzing/all_formats.dict Sat May 11 23:01:40 2024 (r20771) @@ -5,7 +5,7 @@ amf="AMF\x0A" ams="Extreme" -ams="AMShdr\x1A\x02\x02" +ams="AMShdr\x1A\x00\x02\x02" #dbm="DBM0" dbm="NAME" @@ -45,7 +45,7 @@ far="\x0D\x0A\x1A" gdm="GDM\xFE" -gdm="GMFS" +gdm="\x0D\x0A\x1AGMFS\x01\x00" imf="IM10" imf="IS10" @@ -198,7 +198,7 @@ psm16="PPAT" ptm="PTMF" -ptm="\x1A\x03\x02" +ptm="\x1A\x03\x02\x00" s3m="SCRM" #s3m="SCRS" Modified: branches/OpenMPT-1.29/contrib/fuzzing/build.sh ============================================================================== --- branches/OpenMPT-1.29/contrib/fuzzing/build.sh Sat May 11 22:27:18 2024 (r20770) +++ branches/OpenMPT-1.29/contrib/fuzzing/build.sh Sat May 11 23:01:40 2024 (r20771) @@ -1,4 +1,4 @@ #!/usr/bin/env bash cd "${0%/*}" cd ../.. -AFL_HARDEN=1 CONFIG=afl make clean all EXAMPLES=0 TEST=0 OPENMPT123=0 NO_VORBIS=1 NO_VORBISFILE=1 NO_MPG123=1 CHECKED_ADDRESS=1 +AFL_USE_ASAN=1 CONFIG=afl make clean all EXAMPLES=0 TEST=0 OPENMPT123=0 NO_VORBIS=1 NO_VORBISFILE=1 NO_MPG123=1 CHECKED_ADDRESS=1 Copied: branches/OpenMPT-1.29/contrib/fuzzing/fuzz.cpp (from r20769, branches/OpenMPT-1.30/contrib/fuzzing/fuzz.cpp) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/OpenMPT-1.29/contrib/fuzzing/fuzz.cpp Sat May 11 23:01:40 2024 (r20771, copy of r20769, branches/OpenMPT-1.30/contrib/fuzzing/fuzz.cpp) @@ -0,0 +1,88 @@ +/* + * fuzz.cpp + * -------- + * Purpose: Tiny libopenmpt user to be used by fuzzing tools + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#include <memory> +#include <cstdint> +#include <cstdlib> + +#include <cerrno> +#include <unistd.h> + +#include <libopenmpt/libopenmpt.h> + +#include "../../common/mptRandom.h" + +#define BUFFERSIZE 450 // shouldn't match OpenMPT's internal mix buffer size (512) +#define SAMPLERATE 22050 + +static int16_t buffer[BUFFERSIZE]; + +static int ErrFunc (int error, void *) +{ + switch (error) + { + case OPENMPT_ERROR_INVALID_ARGUMENT: + case OPENMPT_ERROR_OUT_OF_RANGE: + case OPENMPT_ERROR_LENGTH: + case OPENMPT_ERROR_DOMAIN: + case OPENMPT_ERROR_LOGIC: + case OPENMPT_ERROR_UNDERFLOW: + case OPENMPT_ERROR_OVERFLOW: + case OPENMPT_ERROR_RANGE: + case OPENMPT_ERROR_RUNTIME: + case OPENMPT_ERROR_EXCEPTION: + std::abort(); + default: + return OPENMPT_ERROR_FUNC_RESULT_NONE; + } +} + +__AFL_FUZZ_INIT(); + +int main( int argc, char * argv[] ) { + (void)argc; + (void)argv; + openmpt_module_create_from_memory2( buffer, BUFFERSIZE, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr ); +#ifdef __AFL_HAVE_MANUAL_CONTROL + __AFL_INIT(); +#endif + + unsigned char *fileBuffer = __AFL_FUZZ_TESTCASE_BUF; // must be after __AFL_INIT and before __AFL_LOOP! + + while (__AFL_LOOP(10000)) { + int fileSize = __AFL_FUZZ_TESTCASE_LEN; + 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; + + // 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 ) + std::abort(); + + openmpt_module_ctl_set( mod, "render.resampler.emulate_amiga", (openmpt_module_get_num_orders( mod ) & 1) ? "0" : "1" ); + // render about a second of the module for fuzzing the actual mix routines + for(int i = 0; i < 50; i++) { + size_t count = openmpt_module_read_mono( mod, SAMPLERATE, BUFFERSIZE, buffer ); + if ( count == 0 ) { + break; + } + } + openmpt_module_set_position_seconds( mod, 1.0 ); + openmpt_module_read_mono( mod, SAMPLERATE, BUFFERSIZE, buffer ); + openmpt_module_set_position_order_row( mod, 3, 16 ); + openmpt_module_read_mono( mod, SAMPLERATE, BUFFERSIZE, buffer ); + + // fuzz string-related stuff + openmpt_free_string ( openmpt_module_get_metadata( mod, "date" ) ); + openmpt_free_string ( openmpt_module_get_metadata( mod, "message" ) ); + openmpt_module_destroy( mod ); + } + return 0; +} Modified: branches/OpenMPT-1.29/contrib/fuzzing/get-afl.sh ============================================================================== --- branches/OpenMPT-1.29/contrib/fuzzing/get-afl.sh Sat May 11 22:27:18 2024 (r20770) +++ branches/OpenMPT-1.29/contrib/fuzzing/get-afl.sh Sat May 11 23:01:40 2024 (r20771) @@ -10,7 +10,7 @@ tar -xzvf $AFL_FILENAME rm $AFL_FILENAME cd AFLplusplus-* -make source-only || exit +make PERFORMANCE=1 source-only || exit cd .. rm -rf afl mv AFLplusplus-* afl \ No newline at end of file |
From: <sv...@op...> - 2024-05-11 20:27:30
|
Author: manx Date: Sat May 11 22:27:18 2024 New Revision: 20770 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20770 Log: [Var] Update gitignore. Modified: trunk/OpenMPT/.gitignore Modified: trunk/OpenMPT/.gitignore ============================================================================== --- trunk/OpenMPT/.gitignore Sat May 11 22:26:30 2024 (r20769) +++ trunk/OpenMPT/.gitignore Sat May 11 22:27:18 2024 (r20770) @@ -860,6 +860,8 @@ /libopenmpt/libopenmpt_plugin_gui.aps /libopenmpt/libopenmpt_version.aps /libopenmpt/in_openmpt/*.d +/libopenmpt/libopenmpt_test/*.d +/libopenmpt/libopenmpt_test/*.o /libopenmpt/plugin-common/*.d /libopenmpt/xmp-openmpt/*.d /mptrack/*.aps |
From: <sv...@op...> - 2024-05-11 20:26:42
|
Author: sagamusix Date: Sat May 11 22:26:30 2024 New Revision: 20769 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20769 Log: Merged revision(s) 20756 from branches/OpenMPT-1.31: Merged revision(s) 20749-20750, 20755 from trunk/OpenMPT: [Mod] Reduce static variable usage in fuzzer program to eventually allow using __AFL_LOOP. ........ [Imp] mptRandom: Add reinit_global_random() function for fuzzer builds to allow deterministic consecutive fuzzer runs in the same process. ........ [Imp] Speed up fuzzing by using persistent mode and shared memory file input. Note: afl++ will report a stability of about 99.x%. According to its debug output, the unstable edges are in WavesReverb and I3DL2Reverb implementations, however the unstable edges that it finds don't make any sense. As a tiny bit of instability in these parts of the code should not hurt overall code coverage, we trade this for the significant gains in speed that persistent mode gives us. ........ ........ Added: branches/OpenMPT-1.30/contrib/fuzzing/fuzz.cpp - copied, changed from r20768, branches/OpenMPT-1.30/contrib/fuzzing/fuzz.c Deleted: branches/OpenMPT-1.30/contrib/fuzzing/fuzz.c Modified: branches/OpenMPT-1.30/ (props changed) branches/OpenMPT-1.30/Makefile branches/OpenMPT-1.30/common/mptRandom.cpp branches/OpenMPT-1.30/common/mptRandom.h Modified: branches/OpenMPT-1.30/Makefile ============================================================================== --- branches/OpenMPT-1.30/Makefile Sat May 11 22:25:28 2024 (r20768) +++ branches/OpenMPT-1.30/Makefile Sat May 11 22:26:30 2024 (r20769) @@ -1747,10 +1747,10 @@ endif endif -contrib/fuzzing/fuzz.o: contrib/fuzzing/fuzz.c - $(INFO) [CC] $< - $(VERYSILENT)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -M -MT$@ $< > $*.d - $(SILENT)$(COMPILE.c) $(OUTPUT_OPTION) $< +contrib/fuzzing/fuzz.o: contrib/fuzzing/fuzz.cpp + $(INFO) [CXX] $< + $(VERYSILENT)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -M -MT$@ $< > $*.d + $(SILENT)$(COMPILE.cc) $(OUTPUT_OPTION) $< bin/fuzz$(EXESUFFIX): contrib/fuzzing/fuzz.o $(OBJECTS_LIBOPENMPT) $(OUTPUT_LIBOPENMPT) $(INFO) [LD] $@ $(SILENT)$(LINK.cc) $(LDFLAGS_LIBOPENMPT) contrib/fuzzing/fuzz.o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) -o $@ Modified: branches/OpenMPT-1.30/common/mptRandom.cpp ============================================================================== --- branches/OpenMPT-1.30/common/mptRandom.cpp Sat May 11 22:25:28 2024 (r20768) +++ branches/OpenMPT-1.30/common/mptRandom.cpp Sat May 11 22:26:30 2024 (r20769) @@ -55,6 +55,16 @@ return g_global_prng; } +#ifdef MPT_BUILD_FUZZER +void reinit_global_random() +{ + global_prng().~thread_safe_prng<mpt::default_prng>(); + global_random_device().~random_device(); + new(&global_random_device()) mpt::random_device{}; + new(&global_prng()) thread_safe_prng<mpt::default_prng>{global_random_device()}; +} +#endif // MPT_BUILD_FUZZER + #endif // MODPLUG_TRACKER && !MPT_BUILD_WINESUPPORT } // namespace mpt Modified: branches/OpenMPT-1.30/common/mptRandom.h ============================================================================== --- branches/OpenMPT-1.30/common/mptRandom.h Sat May 11 22:25:28 2024 (r20768) +++ branches/OpenMPT-1.30/common/mptRandom.h Sat May 11 22:26:30 2024 (r20769) @@ -128,6 +128,10 @@ mpt::random_device & global_random_device(); mpt::thread_safe_prng<mpt::default_prng> & global_prng(); +#ifdef MPT_BUILD_FUZZER +void reinit_global_random(); +#endif // MPT_BUILD_FUZZER + #if defined(MODPLUG_TRACKER) && !defined(MPT_BUILD_WINESUPPORT) void set_global_random_device(mpt::random_device *rd); void set_global_prng(mpt::thread_safe_prng<mpt::default_prng> *rng); Copied and modified: branches/OpenMPT-1.30/contrib/fuzzing/fuzz.cpp (from r20768, branches/OpenMPT-1.30/contrib/fuzzing/fuzz.c) ============================================================================== --- branches/OpenMPT-1.30/contrib/fuzzing/fuzz.c Sat May 11 22:25:28 2024 (r20768, copy source) +++ branches/OpenMPT-1.30/contrib/fuzzing/fuzz.cpp Sat May 11 22:26:30 2024 (r20769) @@ -1,59 +1,88 @@ /* - * fuzz.c - * ------ + * fuzz.cpp + * -------- * Purpose: Tiny libopenmpt user to be used by fuzzing tools * Notes : (currently none) * Authors: OpenMPT Devs * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. */ -#include <memory.h> -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#include <memory> +#include <cstdint> +#include <cstdlib> -#include <errno.h> +#include <cerrno> #include <unistd.h> #include <libopenmpt/libopenmpt.h> -#include <libopenmpt/libopenmpt_stream_callbacks_file.h> + +#include "../../common/mptRandom.h" #define BUFFERSIZE 450 // shouldn't match OpenMPT's internal mix buffer size (512) #define SAMPLERATE 22050 static int16_t buffer[BUFFERSIZE]; +static int ErrFunc (int error, void *) +{ + switch (error) + { + case OPENMPT_ERROR_INVALID_ARGUMENT: + case OPENMPT_ERROR_OUT_OF_RANGE: + case OPENMPT_ERROR_LENGTH: + case OPENMPT_ERROR_DOMAIN: + case OPENMPT_ERROR_LOGIC: + case OPENMPT_ERROR_UNDERFLOW: + case OPENMPT_ERROR_OVERFLOW: + case OPENMPT_ERROR_RANGE: + case OPENMPT_ERROR_RUNTIME: + case OPENMPT_ERROR_EXCEPTION: + std::abort(); + default: + return OPENMPT_ERROR_FUNC_RESULT_NONE; + } +} + +__AFL_FUZZ_INIT(); + int main( int argc, char * argv[] ) { - static FILE * file = NULL; - static openmpt_module * mod = NULL; - static size_t count = 0; - static int i = 0; (void)argc; + (void)argv; + openmpt_module_create_from_memory2( buffer, BUFFERSIZE, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr ); #ifdef __AFL_HAVE_MANUAL_CONTROL __AFL_INIT(); #endif - file = fopen( argv[1], "rb" ); - mod = openmpt_module_create( openmpt_stream_get_file_callbacks(), file, NULL, NULL, NULL ); - fclose( file ); - if ( mod == NULL ) return 1; - openmpt_module_ctl_set( mod, "render.resampler.emulate_amiga", (openmpt_module_get_num_orders( mod ) & 1) ? "0" : "1" ); - /* render about a second of the module for fuzzing the actual mix routines */ - for(; i < 50; i++) { - count = openmpt_module_read_mono( mod, SAMPLERATE, BUFFERSIZE, buffer ); - if ( count == 0 ) { - break; + + unsigned char *fileBuffer = __AFL_FUZZ_TESTCASE_BUF; // must be after __AFL_INIT and before __AFL_LOOP! + + while (__AFL_LOOP(10000)) { + int fileSize = __AFL_FUZZ_TESTCASE_LEN; + 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; + + // 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 ) + std::abort(); + + openmpt_module_ctl_set( mod, "render.resampler.emulate_amiga", (openmpt_module_get_num_orders( mod ) & 1) ? "0" : "1" ); + // render about a second of the module for fuzzing the actual mix routines + for(int i = 0; i < 50; i++) { + size_t count = openmpt_module_read_mono( mod, SAMPLERATE, BUFFERSIZE, buffer ); + if ( count == 0 ) { + break; + } } + openmpt_module_set_position_seconds( mod, 1.0 ); + openmpt_module_read_mono( mod, SAMPLERATE, BUFFERSIZE, buffer ); + openmpt_module_set_position_order_row( mod, 3, 16 ); + openmpt_module_read_mono( mod, SAMPLERATE, BUFFERSIZE, buffer ); + + // fuzz string-related stuff + openmpt_free_string ( openmpt_module_get_metadata( mod, "date" ) ); + openmpt_free_string ( openmpt_module_get_metadata( mod, "message" ) ); + openmpt_module_destroy( mod ); } - openmpt_module_set_position_seconds( mod, 1.0 ); - openmpt_module_read_mono( mod, SAMPLERATE, BUFFERSIZE, buffer ); - openmpt_module_set_position_order_row( mod, 3, 16 ); - openmpt_module_read_mono( mod, SAMPLERATE, BUFFERSIZE, buffer ); - - /* fuzz string-related stuff */ - openmpt_free_string ( openmpt_module_get_metadata( mod, "date" ) ); - openmpt_free_string ( openmpt_module_get_metadata( mod, "message" ) ); - openmpt_module_destroy( mod ); return 0; } |
From: <sv...@op...> - 2024-05-11 20:25:34
|
Author: manx Date: Sat May 11 22:25:28 2024 New Revision: 20768 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20768 Log: [Var] Set svn:ignore. Modified: trunk/OpenMPT/libopenmpt/libopenmpt_test/ (props changed) |
From: <sv...@op...> - 2024-05-11 20:24:26
|
Author: manx Date: Sat May 11 22:24:19 2024 New Revision: 20767 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20767 Log: [Fix/Reg] Force optimization down to -O1 when building with GCC 14. GCC 14 has shown severe miscompilation of inline functions that has caused the test suite to crash on MinGW-w64 amd64 builds. This is a drastic safety measure until GCC fixes their bug. The performance impact is roughly ~15%. Modified: trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/src/mpt/base/detect_quirks.hpp trunk/OpenMPT/src/mpt/check/compiler.hpp Modified: trunk/OpenMPT/common/BuildSettings.h ============================================================================== --- trunk/OpenMPT/common/BuildSettings.h Sat May 11 22:23:38 2024 (r20766) +++ trunk/OpenMPT/common/BuildSettings.h Sat May 11 22:24:19 2024 (r20767) @@ -388,6 +388,16 @@ #endif // MPT_COMPILER_MSVC +#if MPT_COMPILER_GCC + +#ifdef MPT_COMPILER_QUIRK_GCC_NO_O2 +#if defined(__OPTIMIZE__) +#pragma GCC optimize("O1") +#endif +#endif // MPT_COMPILER_QUIRK_GCC_NO_O2 + +#endif // MPT_COMPILER_GCC + #if MPT_COMPILER_CLANG #if defined(MPT_BUILD_MSVC) Modified: trunk/OpenMPT/src/mpt/base/detect_quirks.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/base/detect_quirks.hpp Sat May 11 22:23:38 2024 (r20766) +++ trunk/OpenMPT/src/mpt/base/detect_quirks.hpp Sat May 11 22:24:19 2024 (r20767) @@ -19,6 +19,16 @@ +#if MPT_GCC_AT_LEAST(14, 0, 0) && MPT_GCC_BEFORE(15, 0, 0) +// GCC 14 causes severe miscompilation of inline functions. +// Link to bug report will follow. +#if defined(__OPTIMIZE__) +#define MPT_COMPILER_QUIRK_GCC_NO_O2 +#endif +#endif + + + #if MPT_OS_DJGPP #define MPT_ARCH_QUIRK_NO_SIMD256 #endif Modified: trunk/OpenMPT/src/mpt/check/compiler.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/check/compiler.hpp Sat May 11 22:23:38 2024 (r20766) +++ trunk/OpenMPT/src/mpt/check/compiler.hpp Sat May 11 22:24:19 2024 (r20767) @@ -7,6 +7,12 @@ #include "mpt/base/detect_quirks.hpp" #include "mpt/base/compiletime_warning.hpp" +#ifndef MPT_CHECK_CXX_IGNORE_WARNING_O2 +#if defined(MPT_COMPILER_QUIRK_GCC_NO_O2) +MPT_WARNING("GCC 14 is known to cause severe miscompilation of inline functions. OpenMPT has forced optimization settings down to -O1. This comes at a roughly 15% performance cost. It is strongly recommended to stay with GCC 13 for the time being. You will need to edit the source to opt-out of this safety guard.") +#endif +#endif + #ifndef MPT_CHECK_CXX_IGNORE_PREPROCESSOR #if defined(MPT_COMPILER_QUIRK_MSVC_OLD_PREPROCESSOR) MPT_WARNING("C++ preprocessor is not standard conformings.") |
From: <sv...@op...> - 2024-05-11 20:23:50
|
Author: sagamusix Date: Sat May 11 22:23:38 2024 New Revision: 20766 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20766 Log: Merged revision(s) 20651 from trunk/OpenMPT: [Var] Fuzzing: AFL_HARDEN and ASan are not compatible in v4.10c. ........ Merged revision(s) 20695-20696 from trunk/OpenMPT: [Imp] Enable host-specific performance optimizations in afl++. ........ [Var] Update fuzzer dictionary. ........ Modified: branches/OpenMPT-1.30/ (props changed) branches/OpenMPT-1.30/contrib/fuzzing/all_formats.dict branches/OpenMPT-1.30/contrib/fuzzing/build.sh branches/OpenMPT-1.30/contrib/fuzzing/get-afl.sh Modified: branches/OpenMPT-1.30/contrib/fuzzing/all_formats.dict ============================================================================== --- branches/OpenMPT-1.30/contrib/fuzzing/all_formats.dict Sat May 11 22:15:02 2024 (r20765) +++ branches/OpenMPT-1.30/contrib/fuzzing/all_formats.dict Sat May 11 22:23:38 2024 (r20766) @@ -5,7 +5,7 @@ amf="AMF\x0A" ams="Extreme" -ams="AMShdr\x1A\x02\x02" +ams="AMShdr\x1A\x00\x02\x02" #dbm="DBM0" dbm="NAME" @@ -49,7 +49,7 @@ fmt="FMTracker\x01\x01" gdm="GDM\xFE" -gdm="GMFS" +gdm="\x0D\x0A\x1AGMFS\x01\x00" imf="IM10" imf="IS10" @@ -202,7 +202,7 @@ psm16="PPAT" ptm="PTMF" -ptm="\x1A\x03\x02" +ptm="\x1A\x03\x02\x00" s3m="SCRM" #s3m="SCRS" Modified: branches/OpenMPT-1.30/contrib/fuzzing/build.sh ============================================================================== --- branches/OpenMPT-1.30/contrib/fuzzing/build.sh Sat May 11 22:15:02 2024 (r20765) +++ branches/OpenMPT-1.30/contrib/fuzzing/build.sh Sat May 11 22:23:38 2024 (r20766) @@ -1,4 +1,4 @@ #!/usr/bin/env bash cd "${0%/*}" cd ../.. -AFL_HARDEN=1 CONFIG=afl make clean all EXAMPLES=0 TEST=0 OPENMPT123=0 NO_VORBIS=1 NO_VORBISFILE=1 NO_MPG123=1 CHECKED_ADDRESS=1 +AFL_USE_ASAN=1 CONFIG=afl make clean all EXAMPLES=0 TEST=0 OPENMPT123=0 NO_VORBIS=1 NO_VORBISFILE=1 NO_MPG123=1 CHECKED_ADDRESS=1 Modified: branches/OpenMPT-1.30/contrib/fuzzing/get-afl.sh ============================================================================== --- branches/OpenMPT-1.30/contrib/fuzzing/get-afl.sh Sat May 11 22:15:02 2024 (r20765) +++ branches/OpenMPT-1.30/contrib/fuzzing/get-afl.sh Sat May 11 22:23:38 2024 (r20766) @@ -12,7 +12,7 @@ tar -xzvf $AFL_FILENAME rm $AFL_FILENAME cd AFLplusplus-* -make source-only || exit +make PERFORMANCE=1 source-only || exit cd .. rm -rf afl mv AFLplusplus-* afl \ No newline at end of file |
From: <sv...@op...> - 2024-05-11 20:15:09
|
Author: sagamusix Date: Sat May 11 22:15:02 2024 New Revision: 20765 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20765 Log: Merged revision(s) 20693, 20742 from trunk/OpenMPT: [Imp] XM: Reject files with impossible pattern header. [Imp] XM: Speed up decoding early if pattern data cannot be read, ignore patterns > MAX_PATTERNS for decoding. ........ [Fix] ULT: Strings are space-padded, not null-terminated. ........ Modified: branches/OpenMPT-1.28/ (props changed) branches/OpenMPT-1.28/soundlib/Load_ult.cpp branches/OpenMPT-1.28/soundlib/Load_xm.cpp Modified: branches/OpenMPT-1.28/soundlib/Load_ult.cpp ============================================================================== --- branches/OpenMPT-1.28/soundlib/Load_ult.cpp Sat May 11 22:13:51 2024 (r20764) +++ branches/OpenMPT-1.28/soundlib/Load_ult.cpp Sat May 11 22:15:02 2024 (r20765) @@ -18,7 +18,7 @@ { char signature[14]; // "MAS_UTrack_V00" uint8 version; // '1'...'4' - char songName[32]; // Song Name, not guaranteed to be null-terminated + char songName[32]; // Song Name, space-padded uint8 messageLength; // Number of Lines }; @@ -50,7 +50,7 @@ { mptSmp.Initialize(); - mpt::String::Read<mpt::String::maybeNullTerminated>(mptSmp.filename, filename); + mpt::String::Read<mpt::String::spacePadded>(mptSmp.filename, filename); if(sizeEnd <= sizeStart) { @@ -400,7 +400,7 @@ } InitializeGlobals(MOD_TYPE_ULT); - mpt::String::Read<mpt::String::maybeNullTerminated>(m_songName, fileHeader.songName); + mpt::String::Read<mpt::String::spacePadded>(m_songName, fileHeader.songName); const MPT_UCHAR_TYPE *versions[] = {UL_("<1.4"), UL_("1.4"), UL_("1.5"), UL_("1.6")}; m_modFormat.formatName = U_("UltraTracker"); @@ -433,7 +433,7 @@ } sampleHeader.ConvertToMPT(Samples[smp]); - mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[smp], sampleHeader.name); + mpt::String::Read<mpt::String::spacePadded>(m_szNames[smp], sampleHeader.name); } ReadOrderFromFile<uint8>(Order(), file, 256, 0xFF, 0xFE); Modified: branches/OpenMPT-1.28/soundlib/Load_xm.cpp ============================================================================== --- branches/OpenMPT-1.28/soundlib/Load_xm.cpp Sat May 11 22:13:51 2024 (r20764) +++ branches/OpenMPT-1.28/soundlib/Load_xm.cpp Sat May 11 22:15:02 2024 (r20765) @@ -128,18 +128,16 @@ for(PATTERNINDEX pat = 0; pat < fileHeader.patterns; pat++) { FileReader::off_t curPos = file.GetPosition(); - uint32 headerSize = file.ReadUint32LE(); - file.Skip(1); // Pack method (= 0) - - ROWINDEX numRows = 64; + const uint32 headerSize = file.ReadUint32LE(); + if(headerSize < 8 || !file.CanRead(headerSize - 4)) + break; + file.Skip(1); // Pack method (= 0) + ROWINDEX numRows; if(fileHeader.version == 0x0102) - { numRows = file.ReadUint8() + 1; - } else - { + else numRows = file.ReadUint16LE(); - } // A packed size of 0 indicates a completely empty pattern. const uint16 packedSize = file.ReadUint16LE(); @@ -152,10 +150,8 @@ file.Seek(curPos + headerSize); FileReader patternChunk = file.ReadChunk(packedSize); - if(!sndFile.Patterns.Insert(pat, numRows) || packedSize == 0) - { + if(pat >= MAX_PATTERNS || !sndFile.Patterns.Insert(pat, numRows) || packedSize == 0) continue; - } enum PatternFlags { @@ -171,6 +167,9 @@ for(auto &m : sndFile.Patterns[pat]) { + if(!file.CanRead(1)) + break; + uint8 info = patternChunk.ReadUint8(); uint8 vol = 0; @@ -925,7 +924,7 @@ if(!p->IsEmpty()) emptyPattern = false; - // Apparently, completely empty patterns are loaded as empty 64-row patterns in FT2, regardless of their original size. + // Completely empty patterns are loaded as empty 64-row patterns in FT2, regardless of their original size. // We have to avoid this, so we add a "break to row 0" command in the last row. if(j == 1 && emptyPattern && numRows != 64) { |
From: <sv...@op...> - 2024-05-11 20:13:58
|
Author: sagamusix Date: Sat May 11 22:13:51 2024 New Revision: 20764 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20764 Log: Merged revision(s) 20693, 20742 from trunk/OpenMPT: [Imp] XM: Reject files with impossible pattern header. [Imp] XM: Speed up decoding early if pattern data cannot be read, ignore patterns > MAX_PATTERNS for decoding. ........ [Fix] ULT: Strings are space-padded, not null-terminated. ........ Modified: branches/OpenMPT-1.29/ (props changed) branches/OpenMPT-1.29/soundlib/Load_ult.cpp branches/OpenMPT-1.29/soundlib/Load_xm.cpp Modified: branches/OpenMPT-1.29/soundlib/Load_ult.cpp ============================================================================== --- branches/OpenMPT-1.29/soundlib/Load_ult.cpp Sat May 11 22:13:28 2024 (r20763) +++ branches/OpenMPT-1.29/soundlib/Load_ult.cpp Sat May 11 22:13:51 2024 (r20764) @@ -18,7 +18,7 @@ { char signature[14]; // "MAS_UTrack_V00" uint8 version; // '1'...'4' - char songName[32]; // Song Name, not guaranteed to be null-terminated + char songName[32]; // Song Name, space-padded uint8 messageLength; // Number of Lines }; @@ -50,7 +50,7 @@ { mptSmp.Initialize(); - mptSmp.filename = mpt::String::ReadBuf(mpt::String::maybeNullTerminated, filename); + mptSmp.filename = mpt::String::ReadBuf(mpt::String::spacePadded, filename); if(sizeEnd <= sizeStart) { @@ -385,7 +385,7 @@ } InitializeGlobals(MOD_TYPE_ULT); - m_songName = mpt::String::ReadBuf(mpt::String::maybeNullTerminated, fileHeader.songName); + m_songName = mpt::String::ReadBuf(mpt::String::spacePadded, fileHeader.songName); const mpt::uchar *versions[] = {UL_("<1.4"), UL_("1.4"), UL_("1.5"), UL_("1.6")}; m_modFormat.formatName = U_("UltraTracker"); @@ -419,7 +419,7 @@ } sampleHeader.ConvertToMPT(Samples[smp]); - m_szNames[smp] = mpt::String::ReadBuf(mpt::String::maybeNullTerminated, sampleHeader.name); + m_szNames[smp] = mpt::String::ReadBuf(mpt::String::spacePadded, sampleHeader.name); } ReadOrderFromFile<uint8>(Order(), file, 256, 0xFF, 0xFE); Modified: branches/OpenMPT-1.29/soundlib/Load_xm.cpp ============================================================================== --- branches/OpenMPT-1.29/soundlib/Load_xm.cpp Sat May 11 22:13:28 2024 (r20763) +++ branches/OpenMPT-1.29/soundlib/Load_xm.cpp Sat May 11 22:13:51 2024 (r20764) @@ -242,18 +242,16 @@ for(PATTERNINDEX pat = 0; pat < fileHeader.patterns; pat++) { FileReader::off_t curPos = file.GetPosition(); - uint32 headerSize = file.ReadUint32LE(); - file.Skip(1); // Pack method (= 0) - - ROWINDEX numRows = 64; + const uint32 headerSize = file.ReadUint32LE(); + if(headerSize < 8 || !file.CanRead(headerSize - 4)) + break; + file.Skip(1); // Pack method (= 0) + ROWINDEX numRows; if(fileHeader.version == 0x0102) - { numRows = file.ReadUint8() + 1; - } else - { + else numRows = file.ReadUint16LE(); - } // A packed size of 0 indicates a completely empty pattern. const uint16 packedSize = file.ReadUint16LE(); @@ -266,10 +264,8 @@ file.Seek(curPos + headerSize); FileReader patternChunk = file.ReadChunk(packedSize); - if(!sndFile.Patterns.Insert(pat, numRows) || packedSize == 0) - { + if(pat >= MAX_PATTERNS || !sndFile.Patterns.Insert(pat, numRows) || packedSize == 0) continue; - } enum PatternFlags { @@ -285,6 +281,9 @@ for(auto &m : sndFile.Patterns[pat]) { + if(!file.CanRead(1)) + break; + uint8 info = patternChunk.ReadUint8(); uint8 vol = 0; @@ -1219,7 +1218,7 @@ if(!p->IsEmpty()) emptyPattern = false; - // Apparently, completely empty patterns are loaded as empty 64-row patterns in FT2, regardless of their original size. + // Completely empty patterns are loaded as empty 64-row patterns in FT2, regardless of their original size. // We have to avoid this, so we add a "break to row 0" command in the last row. if(j == 1 && emptyPattern && numRows != 64) { |
From: <sv...@op...> - 2024-05-11 20:13:40
|
Author: sagamusix Date: Sat May 11 22:13:28 2024 New Revision: 20763 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20763 Log: Merged revision(s) 20742 from trunk/OpenMPT: [Fix] ULT: Strings are space-padded, not null-terminated. ........ Modified: branches/OpenMPT-1.30/ (props changed) branches/OpenMPT-1.30/soundlib/Load_ult.cpp Modified: branches/OpenMPT-1.30/soundlib/Load_ult.cpp ============================================================================== --- branches/OpenMPT-1.30/soundlib/Load_ult.cpp Sat May 11 22:11:21 2024 (r20762) +++ branches/OpenMPT-1.30/soundlib/Load_ult.cpp Sat May 11 22:13:28 2024 (r20763) @@ -18,7 +18,7 @@ { char signature[14]; // "MAS_UTrack_V00" uint8 version; // '1'...'4' - char songName[32]; // Song Name, not guaranteed to be null-terminated + char songName[32]; // Song Name, space-padded uint8 messageLength; // Number of Lines }; @@ -51,7 +51,7 @@ mptSmp.Initialize(); mptSmp.Set16BitCuePoints(); - mptSmp.filename = mpt::String::ReadBuf(mpt::String::maybeNullTerminated, filename); + mptSmp.filename = mpt::String::ReadBuf(mpt::String::spacePadded, filename); if(sizeEnd <= sizeStart) { @@ -408,7 +408,7 @@ } InitializeGlobals(MOD_TYPE_ULT); - m_songName = mpt::String::ReadBuf(mpt::String::maybeNullTerminated, fileHeader.songName); + m_songName = mpt::String::ReadBuf(mpt::String::spacePadded, fileHeader.songName); const mpt::uchar *versions[] = {UL_("<1.4"), UL_("1.4"), UL_("1.5"), UL_("1.6")}; m_modFormat.formatName = U_("UltraTracker"); @@ -442,7 +442,7 @@ } sampleHeader.ConvertToMPT(Samples[smp]); - m_szNames[smp] = mpt::String::ReadBuf(mpt::String::maybeNullTerminated, sampleHeader.name); + m_szNames[smp] = mpt::String::ReadBuf(mpt::String::spacePadded, sampleHeader.name); } ReadOrderFromFile<uint8>(Order(), file, 256, 0xFF, 0xFE); |
From: <sv...@op...> - 2024-05-11 20:11:33
|
Author: sagamusix Date: Sat May 11 22:11:21 2024 New Revision: 20762 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20762 Log: Merged revision(s) 20693 from trunk/OpenMPT: [Imp] XM: Reject files with impossible pattern header. [Imp] XM: Speed up decoding early if pattern data cannot be read, ignore patterns > MAX_PATTERNS for decoding. ........ Modified: branches/OpenMPT-1.30/ (props changed) branches/OpenMPT-1.30/soundlib/Load_xm.cpp Modified: branches/OpenMPT-1.30/soundlib/Load_xm.cpp ============================================================================== --- branches/OpenMPT-1.30/soundlib/Load_xm.cpp Sat May 11 21:51:49 2024 (r20761) +++ branches/OpenMPT-1.30/soundlib/Load_xm.cpp Sat May 11 22:11:21 2024 (r20762) @@ -244,18 +244,16 @@ for(PATTERNINDEX pat = 0; pat < fileHeader.patterns; pat++) { FileReader::off_t curPos = file.GetPosition(); - uint32 headerSize = file.ReadUint32LE(); - file.Skip(1); // Pack method (= 0) - - ROWINDEX numRows = 64; + const uint32 headerSize = file.ReadUint32LE(); + if(headerSize < 8 || !file.CanRead(headerSize - 4)) + break; + file.Skip(1); // Pack method (= 0) + ROWINDEX numRows; if(fileHeader.version == 0x0102) - { numRows = file.ReadUint8() + 1; - } else - { + else numRows = file.ReadUint16LE(); - } // A packed size of 0 indicates a completely empty pattern. const uint16 packedSize = file.ReadUint16LE(); @@ -268,10 +266,8 @@ file.Seek(curPos + headerSize); FileReader patternChunk = file.ReadChunk(packedSize); - if(!sndFile.Patterns.Insert(pat, numRows) || packedSize == 0) - { + if(pat >= MAX_PATTERNS || !sndFile.Patterns.Insert(pat, numRows) || packedSize == 0) continue; - } enum PatternFlags { @@ -287,6 +283,9 @@ for(auto &m : sndFile.Patterns[pat]) { + if(!file.CanRead(1)) + break; + uint8 info = patternChunk.ReadUint8(); uint8 vol = 0; @@ -1217,7 +1216,7 @@ if(!p->IsEmpty()) emptyPattern = false; - // Apparently, completely empty patterns are loaded as empty 64-row patterns in FT2, regardless of their original size. + // Completely empty patterns are loaded as empty 64-row patterns in FT2, regardless of their original size. // We have to avoid this, so we add a "break to row 0" command in the last row. if(j == 1 && emptyPattern && numRows != 64) { |
From: <sv...@op...> - 2024-05-11 19:52:01
|
Author: sagamusix Date: Sat May 11 21:51:49 2024 New Revision: 20761 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20761 Log: Merged revision(s) 20693 from trunk/OpenMPT: [Imp] XM: Reject files with impossible pattern header. [Imp] XM: Speed up decoding early if pattern data cannot be read, ignore patterns > MAX_PATTERNS for decoding. ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/soundlib/Load_xm.cpp Modified: branches/OpenMPT-1.31/soundlib/Load_xm.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Load_xm.cpp Sat May 11 21:16:14 2024 (r20760) +++ branches/OpenMPT-1.31/soundlib/Load_xm.cpp Sat May 11 21:51:49 2024 (r20761) @@ -244,18 +244,16 @@ for(PATTERNINDEX pat = 0; pat < fileHeader.patterns; pat++) { FileReader::off_t curPos = file.GetPosition(); - uint32 headerSize = file.ReadUint32LE(); - file.Skip(1); // Pack method (= 0) - - ROWINDEX numRows = 64; + const uint32 headerSize = file.ReadUint32LE(); + if(headerSize < 8 || !file.CanRead(headerSize - 4)) + break; + file.Skip(1); // Pack method (= 0) + ROWINDEX numRows; if(fileHeader.version == 0x0102) - { numRows = file.ReadUint8() + 1; - } else - { + else numRows = file.ReadUint16LE(); - } // A packed size of 0 indicates a completely empty pattern. const uint16 packedSize = file.ReadUint16LE(); @@ -268,10 +266,8 @@ file.Seek(curPos + headerSize); FileReader patternChunk = file.ReadChunk(packedSize); - if(!sndFile.Patterns.Insert(pat, numRows) || packedSize == 0) - { + if(pat >= MAX_PATTERNS || !sndFile.Patterns.Insert(pat, numRows) || packedSize == 0) continue; - } enum PatternFlags { @@ -287,6 +283,9 @@ for(auto &m : sndFile.Patterns[pat]) { + if(!file.CanRead(1)) + break; + uint8 info = patternChunk.ReadUint8(); uint8 vol = 0, command = 0; @@ -1297,7 +1296,7 @@ if(!p->IsEmpty()) emptyPattern = false; - // Apparently, completely empty patterns are loaded as empty 64-row patterns in FT2, regardless of their original size. + // Completely empty patterns are loaded as empty 64-row patterns in FT2, regardless of their original size. // We have to avoid this, so we add a "break to row 0" command in the last row. if(j == 1 && emptyPattern && numRows != 64) { |
From: <sv...@op...> - 2024-05-11 19:16:26
|
Author: sagamusix Date: Sat May 11 21:16:14 2024 New Revision: 20760 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20760 Log: [Fix] IT: Do not got back to sample sustain loop on portamento-ed note after key-off (test cases: SampleSustainAfterPorta.it, SampleSustainAfterPortaCompatGxx.it, SampleSustainAfterPortaInstrMode.it) [Mod] OpenMPT: Version is now 1.32.00.13 Modified: trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/UpgradeModule.cpp Modified: trunk/OpenMPT/common/versionNumber.h ============================================================================== --- trunk/OpenMPT/common/versionNumber.h Sat May 11 17:31:57 2024 (r20759) +++ trunk/OpenMPT/common/versionNumber.h Sat May 11 21:16:14 2024 (r20760) @@ -18,6 +18,6 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 32 #define VER_MINOR 00 -#define VER_MINORMINOR 12 +#define VER_MINORMINOR 13 OPENMPT_NAMESPACE_END Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp ============================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp Sat May 11 17:31:57 2024 (r20759) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp Sat May 11 21:16:14 2024 (r20760) @@ -709,6 +709,7 @@ case kITResetFilterOnPortaSmpChange: desc = _T("Reset filter on portamento if new note plays a different sample"); break; case kITInitialNoteMemory: desc = _T("Initial Last Note Memory of each channel is C-0 instead of No Note"); break; case kPluginDefaultProgramAndBank1: desc = _T("Assume initial plugin MIDI program and bank number is 1"); break; + case kITNoSustainOnPortamento: desc = _T("Portamento after note-off does not re-enable sample sustain loop"); break; default: MPT_ASSERT_NOTREACHED(); } Modified: trunk/OpenMPT/soundlib/Snd_defs.h ============================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h Sat May 11 17:31:57 2024 (r20759) +++ trunk/OpenMPT/soundlib/Snd_defs.h Sat May 11 21:16:14 2024 (r20760) @@ -565,6 +565,7 @@ kITResetFilterOnPortaSmpChange, // Filter is reset on portamento if sample is swapped kITInitialNoteMemory, // Initial "last note memory" for each channel is C-0 and not "no note" kPluginDefaultProgramAndBank1, // Default program and bank is set to 1 for plugins, so if an instrument is set to either of those, the program / bank change event is not sent to the plugin + kITNoSustainOnPortamento, // Do not re-enable sustain loop on portamento, even when switching between samples // Add new play behaviours here. Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp Sat May 11 17:31:57 2024 (r20759) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp Sat May 11 21:16:14 2024 (r20760) @@ -1595,9 +1595,15 @@ return; } + const bool wasKeyOff = chn.dwFlags[CHN_KEYOFF]; + // Tone-Portamento doesn't reset the pingpong direction flag if(bPorta && pSmp == chn.pModSample && pSmp != nullptr) { + // IT compatibility: Instrument change but sample stays the same: still reset the key-off flags + // Test case: SampleSustainAfterPortaInstrMode.it + if(instrumentChanged && pIns && m_playBehaviour[kITNoSustainOnPortamento]) + chn.dwFlags.reset(CHN_KEYOFF | CHN_NOTEFADE); // If channel length is 0, we cut a previous sample using SCx. In that case, we have to update sample length, loop points, etc... if(GetType() & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT) && chn.nLength != 0) return; @@ -1706,7 +1712,9 @@ } chn.m_PortamentoFineSteps = 0; - if(chn.dwFlags[CHN_SUSTAINLOOP]) + // IT compatibility: Do not reset sustain loop status when using portamento after key-off + // Test case: SampleSustainAfterPorta.it, SampleSustainAfterPortaCompatGxx.it, SampleSustainAfterPortaInstrMode.it + if(chn.dwFlags[CHN_SUSTAINLOOP] && (!m_playBehaviour[kITNoSustainOnPortamento] || !bPorta || (pIns && !wasKeyOff))) { chn.nLoopStart = pSmp->nSustainStart; chn.nLoopEnd = pSmp->nSustainEnd; Modified: trunk/OpenMPT/soundlib/Sndfile.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp Sat May 11 17:31:57 2024 (r20759) +++ trunk/OpenMPT/soundlib/Sndfile.cpp Sat May 11 21:16:14 2024 (r20760) @@ -1124,6 +1124,10 @@ switch(type) { case MOD_TYPE_MPT: + playBehaviour.set(kOPLFlexibleNoteOff); + playBehaviour.set(kOPLwithNNA); + playBehaviour.set(kOPLNoteOffOnNoteChange); + [[fallthrough]]; case MOD_TYPE_IT: playBehaviour.set(MSF_COMPATIBLE_PLAY); playBehaviour.set(kPeriodsAreHertz); @@ -1178,12 +1182,7 @@ playBehaviour.set(kITPitchPanSeparation); playBehaviour.set(kITResetFilterOnPortaSmpChange); playBehaviour.set(kITInitialNoteMemory); - if(type == MOD_TYPE_MPT) - { - playBehaviour.set(kOPLFlexibleNoteOff); - playBehaviour.set(kOPLwithNNA); - playBehaviour.set(kOPLNoteOffOnNoteChange); - } + playBehaviour.set(kITNoSustainOnPortamento); break; case MOD_TYPE_XM: Modified: trunk/OpenMPT/soundlib/UpgradeModule.cpp ============================================================================== --- trunk/OpenMPT/soundlib/UpgradeModule.cpp Sat May 11 17:31:57 2024 (r20759) +++ trunk/OpenMPT/soundlib/UpgradeModule.cpp Sat May 11 21:16:14 2024 (r20760) @@ -596,6 +596,7 @@ { kITPitchPanSeparation, MPT_V("1.30.00.53") }, { kITResetFilterOnPortaSmpChange, MPT_V("1.30.08.02") }, { kITInitialNoteMemory, MPT_V("1.31.00.25") }, + { kITNoSustainOnPortamento, MPT_V("1.32.00.13") }, }; for(const auto &b : behaviours) |
From: <sv...@op...> - 2024-05-11 15:32:10
|
Author: sagamusix Date: Sat May 11 17:31:57 2024 New Revision: 20759 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20759 Log: Merged revision(s) 20744 from trunk/OpenMPT: [Mod] XM: All MPT versions up to v1.11 set both normal and pingpong loop flags for pingpong-looped samples, not just MPT 1.09. Apart from this, a file made with MPT 1.06 or newer will be bit-identical when re-saved in MPT 1.16. Make the version reporting more precise. ........ Merged revision(s) 20747-20748 from trunk/OpenMPT: [Imp] XM: Improve detection of MPT-made files, and tell them apart from files created with PlayerPRO. ........ [Var] XM: Document more cases of unusal instrument header sizes. ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/soundlib/Load_xm.cpp Modified: branches/OpenMPT-1.31/soundlib/Load_xm.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Load_xm.cpp Sat May 11 17:30:11 2024 (r20758) +++ branches/OpenMPT-1.31/soundlib/Load_xm.cpp Sat May 11 17:31:57 2024 (r20759) @@ -359,19 +359,20 @@ enum TrackerVersions { - verUnknown = 0x00, // Probably not made with MPT - verOldModPlug = 0x01, // Made with MPT Alpha / Beta - verNewModPlug = 0x02, // Made with MPT (not Alpha / Beta) - verModPlug1_09 = 0x04, // Made with MPT 1.09 or possibly other version - verOpenMPT = 0x08, // Made with OpenMPT - verConfirmed = 0x10, // We are very sure that we found the correct tracker version. - - verFT2Generic = 0x20, // "FastTracker v2.00", but FastTracker has NOT been ruled out - verOther = 0x40, // Something we don't know, testing for DigiTrakker. - verFT2Clone = 0x80, // NOT FT2: itype changed between instruments, or \0 found in song title - verDigiTrakker = 0x100, // Probably DigiTrakker - verUNMO3 = 0x200, // TODO: UNMO3-ed XMs are detected as MPT 1.16 - verEmptyOrders = 0x400, // Allow empty order list like in OpenMPT (FT2 just plays pattern 0 if the order list is empty according to the header) + verUnknown = 0x00, // Probably not made with MPT + verOldModPlug = 0x01, // Made with MPT Alpha / Beta + verNewModPlug = 0x02, // Made with MPT (not Alpha / Beta) + verModPlugBidiFlag = 0x04, // MPT up to v1.11 sets both normal loop and pingpong loop flags + verOpenMPT = 0x08, // Made with OpenMPT + verConfirmed = 0x10, // We are very sure that we found the correct tracker version. + + verFT2Generic = 0x20, // "FastTracker v2.00", but FastTracker has NOT been ruled out + verOther = 0x40, // Something we don't know, testing for DigiTrakker. + verFT2Clone = 0x80, // NOT FT2: itype changed between instruments, or \0 found in song title + verPlayerPRO = 0x100, // Could be PlayerPRO + verDigiTrakker = 0x200, // Probably DigiTrakker + verUNMO3 = 0x400, // TODO: UNMO3-ed XMs are detected as MPT 1.16 + verEmptyOrders = 0x800, // Allow empty order list like in OpenMPT (FT2 just plays pattern 0 if the order list is empty according to the header) }; DECLARE_FLAGSET(TrackerVersions) @@ -606,13 +607,30 @@ if(!memcmp(fileHeader.trackerName, "FastTracker v2.00 ", 20) && fileHeader.size == 276) { + const std::string_view songName{fileHeader.songName, sizeof(fileHeader.songName)}; if(fileHeader.version < 0x0104) + { madeWith = verFT2Generic | verConfirmed; - else if(memchr(fileHeader.songName, '\0', 20) != nullptr) + } else if(const auto firstNull = songName.find('\0'); firstNull != std::string_view::npos) + { // FT2 pads the song title with spaces, some other trackers use null chars - madeWith = verFT2Clone | verNewModPlug | verEmptyOrders; - else - madeWith = verFT2Generic | verNewModPlug; + // PlayerPRO filles the remaining buffer after the null terminator with space characters. + // PlayerPRO does not support song restart position. + if(fileHeader.restartPos) + madeWith = verFT2Clone | verNewModPlug | verEmptyOrders; + else if(firstNull == songName.size() - 1) + madeWith = verFT2Clone | verNewModPlug | verPlayerPRO | verEmptyOrders; + else if(songName.find_first_not_of(' ', firstNull + 1) == std::string_view::npos) + madeWith = verPlayerPRO | verConfirmed; + else + madeWith = verFT2Clone | verNewModPlug | verEmptyOrders; + } else + { + if(fileHeader.restartPos) + madeWith = verFT2Generic | verNewModPlug; + else + madeWith = verFT2Generic | verNewModPlug | verPlayerPRO; + } } else if(!memcmp(fileHeader.trackerName, "FastTracker v 2.00 ", 20)) { // MPT 1.0 (exact version to be determined later) @@ -673,10 +691,8 @@ m_SongFlags.reset(); m_SongFlags.set(SONG_LINEARSLIDES, (fileHeader.flags & XMFileHeader::linearSlides) != 0); m_SongFlags.set(SONG_EXFILTERRANGE, (fileHeader.flags & XMFileHeader::extendedFilterRange) != 0); - if(m_SongFlags[SONG_EXFILTERRANGE] && madeWith == (verFT2Generic | verNewModPlug)) - { - madeWith = verFT2Clone | verNewModPlug | verConfirmed; - } + if(m_SongFlags[SONG_EXFILTERRANGE] && madeWith[verNewModPlug]) + madeWith = verFT2Clone | verNewModPlug | verConfirmed | verEmptyOrders; ReadOrderFromFile<uint8>(Order(), file, fileHeader.orders); if(fileHeader.orders == 0 && !madeWith[verEmptyOrders]) @@ -696,9 +712,11 @@ // In case of XM versions < 1.04, we need to memorize the sample flags for all samples, as they are not stored immediately after the sample headers. std::vector<SampleIO> sampleFlags; uint8 sampleReserved = 0; - int instrType = -1; + int16 lastInstrType = -1, lastSampleReserved = -1; + int64 lastSampleHeaderSize = -1; bool unsupportedSamples = false; bool anyADPCM = false; + bool instrumentWithSamplesEncountered = false; // Reading instruments for(INSTRUMENTINDEX instr = 1; instr <= m_nInstruments; instr++) @@ -744,11 +762,25 @@ else if(madeWith[verFT2Clone | verFT2Generic] && instrHeader.size != 33) { // Sure isn't FT2. - // Note: FT2 NORMALLY writes shdr=40 for all samples, but sometimes it - // just happens to write random garbage there instead. Surprise! - // Note: 4-mat's eternity.xm has an instrument header size of 29. + // 4-mat's eternity.xm has an empty instruments with a header size of 29. + // Another module using that size is funky_dumbass.xm. Mysterious! + // Note: This may happen when the XM Commenter by Aka (XMC.EXE) adds empty instruments at the end of the list, + // which would explain the latter case, but in eternity.xm the empty slots are not at the end of the list. madeWith = verUnknown; } + if(instrHeader.size != 33) + { + madeWith.reset(verPlayerPRO); + } else if(instrHeader.sampleHeaderSize > sizeof(XMSample) && madeWith[verPlayerPRO]) + { + // Older PlayerPRO versions appear to write garbage in the sampleHeaderSize field, and it's different for each sample. + // Note: FT2 NORMALLY writes sampleHeaderSize=40 for all samples, but for any instruments before the first + // instrument that has numSamples != 0, sampleHeaderSize will be uninitialized. It will always be the same + // value, though. + if(instrumentWithSamplesEncountered || (lastSampleHeaderSize != -1 && instrHeader.sampleHeaderSize != lastSampleHeaderSize)) + madeWith = verPlayerPRO | verConfirmed; + lastSampleHeaderSize = instrHeader.sampleHeaderSize; + } } if(AllocateInstrument(instr) == nullptr) @@ -758,24 +790,38 @@ instrHeader.ConvertToMPT(*Instruments[instr]); - if(instrType == -1) + if(lastInstrType == -1) { - instrType = instrHeader.type; - } else if(instrType != instrHeader.type && madeWith[verFT2Generic]) + lastInstrType = instrHeader.type; + } else if(lastInstrType != instrHeader.type && madeWith[verFT2Generic]) { // FT2 writes some random junk for the instrument type field, // but it's always the SAME junk for every instrument saved. + // Note: This may happen when running an FT2-made XM through PutInst and adding new instrument slots. madeWith.reset(verFT2Generic); madeWith.set(verFT2Clone); } if(instrHeader.numSamples > 0) { + instrumentWithSamplesEncountered = true; + // Yep, there are some samples associated with this instrument. + + // If MIDI settings are present, this is definitely not an old MPT or PlayerPRO. if((instrHeader.instrument.midiEnabled | instrHeader.instrument.midiChannel | instrHeader.instrument.midiProgram | instrHeader.instrument.muteComputer) != 0) - { - // Definitely not an old MPT. - madeWith.reset(verOldModPlug | verNewModPlug); + madeWith.reset(verOldModPlug | verNewModPlug | verPlayerPRO); + if(instrHeader.size != 263 || instrHeader.type != 0) + madeWith.reset(verPlayerPRO); + if(!madeWith[verConfirmed] && madeWith[verPlayerPRO]) + { + // Note: Earlier (?) PlayerPRO versions do not seem to set the loop points to 0xFF (george_megas_-_q.xm) + if((!(instrHeader.instrument.volFlags & XMInstrument::envLoop) && instrHeader.instrument.volLoopStart == 0xFF && instrHeader.instrument.volLoopEnd == 0xFF) + || (!(instrHeader.instrument.panFlags & XMInstrument::envLoop) && instrHeader.instrument.panLoopStart == 0xFF && instrHeader.instrument.panLoopEnd == 0xFF)) + { + madeWith.set(verConfirmed); + madeWith.reset(verNewModPlug); + } } // Read sample headers @@ -810,6 +856,18 @@ sampleSize[sample] = sampleHeader.length; sampleReserved |= sampleHeader.reserved; + if(sampleHeader.reserved != 0 && sampleHeader.reserved != 0xAD) + madeWith.reset(verOldModPlug | verNewModPlug | verOpenMPT); + + if(lastSampleReserved == -1) + lastSampleReserved = sampleHeader.reserved; + else if(lastSampleReserved != sampleHeader.reserved) + madeWith.reset(verPlayerPRO); + if(sampleHeader.pan != 128) + madeWith.reset(verPlayerPRO); + if((sampleHeader.finetune & 0x0F) && sampleHeader.finetune != 127) + madeWith.reset(verPlayerPRO); + if(sample < sampleSlots.size()) { SAMPLEINDEX mptSample = sampleSlots[sample]; @@ -818,12 +876,16 @@ instrHeader.instrument.ApplyAutoVibratoToMPT(Samples[mptSample]); m_szNames[mptSample] = mpt::String::ReadBuf(mpt::String::spacePadded, sampleHeader.name); - - if((sampleHeader.flags & 3) == 3 && madeWith[verNewModPlug]) + if(madeWith[verFT2Generic | verFT2Clone] && madeWith[verNewModPlug | verPlayerPRO] && !madeWith[verConfirmed] + && (sampleHeader.reserved > 22 || std::find_if(std::begin(sampleHeader.name) + sampleHeader.reserved, std::end(sampleHeader.name), [](char c) { return c != ' '; }) != std::end(sampleHeader.name))) { - // MPT 1.09 and maybe newer / older versions set both loop flags for bidi loops. - madeWith.set(verModPlug1_09); + // FT2 stores the sample name length here (it just copies the entire Pascal string, but that string might have ended with spaces even before space-padding it in the file, so we cannot do an exact length comparison) + madeWith.reset(verFT2Generic); + madeWith.set(verFT2Clone | verConfirmed); } + + if((sampleHeader.flags & 3) == 3 && madeWith[verNewModPlug]) + madeWith.set(verModPlugBidiFlag); } if(sampleFlags.back().GetEncoding() == SampleIO::ADPCM) anyADPCM = true; @@ -882,6 +944,7 @@ { m_songMessage.Read(file, file.ReadUint32LE(), SongMessage::leCR); madeWith.set(verConfirmed); + madeWith.reset(verPlayerPRO); } // Read midi config: "MIDI" @@ -892,6 +955,7 @@ m_MidiCfg.Sanitize(); hasMidiConfig = true; madeWith.set(verConfirmed); + madeWith.reset(verPlayerPRO); } // Read pattern names: "PNAM" @@ -906,6 +970,7 @@ Patterns[pat].SetName(patName); } madeWith.set(verConfirmed); + madeWith.reset(verPlayerPRO); } // Read channel names: "CNAM" @@ -917,6 +982,7 @@ file.ReadString<mpt::String::maybeNullTerminated>(ChnSettings[chn].szName, MAX_CHANNELNAME); } madeWith.set(verConfirmed); + madeWith.reset(verPlayerPRO); } // Read mix plugins information @@ -927,19 +993,27 @@ if(file.GetPosition() != oldPos) { madeWith.set(verConfirmed); + madeWith.reset(verPlayerPRO); } } if(madeWith[verConfirmed]) { - if(madeWith[verModPlug1_09]) + if(madeWith[verModPlugBidiFlag]) { - m_dwLastSavedWithVersion = MPT_V("1.09.00.00"); - madeWithTracker = U_("ModPlug Tracker 1.09"); - } else if(madeWith[verNewModPlug]) + m_dwLastSavedWithVersion = MPT_V("1.11"); + madeWithTracker = U_("ModPlug Tracker 1.0 - 1.11"); + } else if(madeWith[verNewModPlug] && !madeWith[verPlayerPRO]) { m_dwLastSavedWithVersion = MPT_V("1.16.00.00"); - madeWithTracker = U_("ModPlug Tracker 1.10 - 1.16"); + madeWithTracker = U_("ModPlug Tracker 1.0 - 1.16"); + } else if(madeWith[verNewModPlug] && madeWith[verPlayerPRO]) + { + m_dwLastSavedWithVersion = MPT_V("1.16"); + madeWithTracker = U_("ModPlug Tracker 1.0 - 1.16 / PlayerPRO"); + } else if(!madeWith[verNewModPlug] && madeWith[verPlayerPRO]) + { + madeWithTracker = U_("PlayerPRO"); } } @@ -986,7 +1060,7 @@ if(madeWithTracker.empty()) { - if(madeWith[verDigiTrakker] && sampleReserved == 0 && (instrType ? instrType : -1) == -1) + if(madeWith[verDigiTrakker] && sampleReserved == 0 && (lastInstrType ? lastInstrType : -1) == -1) { madeWithTracker = U_("DigiTrakker"); } else if(madeWith[verFT2Generic]) |
From: <sv...@op...> - 2024-05-11 15:30:19
|
Author: sagamusix Date: Sat May 11 17:30:11 2024 New Revision: 20758 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20758 Log: Merged revision(s) 20742, 20745-20746 from trunk/OpenMPT: [Fix] ULT: Strings are space-padded, not null-terminated. ........ [Imp] S3M: Detect files saved with PlayerPRO on intel platforms, where it tries to disguise as Scream Tracker 3 but the tracker ID bytes are swapped. Supposedly this will not work for files saved on Motorola Macs. ........ [Imp] S3M: Tell Velvet Studio apart from MPT more reliably. [Imp] S3M: Detect PlayerPRO when running on big-endian platforms (assumption based on source - I have not searched for any such S3M files yet.) ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/soundlib/Load_s3m.cpp branches/OpenMPT-1.31/soundlib/Load_ult.cpp branches/OpenMPT-1.31/soundlib/S3MTools.h Modified: branches/OpenMPT-1.31/soundlib/Load_s3m.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Load_s3m.cpp Sat May 11 09:36:53 2024 (r20757) +++ branches/OpenMPT-1.31/soundlib/Load_s3m.cpp Sat May 11 17:30:11 2024 (r20758) @@ -248,7 +248,7 @@ madeWithTracker = U_("Akord"); break; case S3MFileHeader::trkScreamTracker: - if(fileHeader.cwtv == S3MFileHeader::trkST3_20 && fileHeader.special == 0 && (fileHeader.ordNum & 0x0F) == 0 && fileHeader.ultraClicks == 0 && (fileHeader.flags & ~0x50) == 0) + if(fileHeader.cwtv == S3MFileHeader::trkST3_20 && fileHeader.special == 0 && (fileHeader.ordNum & 0x0F) == 0 && fileHeader.ultraClicks == 0 && (fileHeader.flags & ~0x50) == 0 && fileHeader.usePanningTable == S3MFileHeader::idPanning) { // MPT and OpenMPT before 1.17.03.02 - Simply keep default (filter) MIDI macros if((fileHeader.masterVolume & 0x80) != 0) @@ -266,7 +266,10 @@ m_playBehaviour.set(kST3LimitPeriod); } else if(fileHeader.cwtv == S3MFileHeader::trkST3_20 && fileHeader.special == 0 && fileHeader.ultraClicks == 0 && fileHeader.flags == 0 && fileHeader.usePanningTable == 0) { - madeWithTracker = U_("Velvet Studio"); + if(fileHeader.globalVol == 64 && fileHeader.masterVolume == 48) + madeWithTracker = U_("PlayerPRO"); + else // Always stereo + madeWithTracker = U_("Velvet Studio"); } else { // ST3.20 should only ever write ultra-click values 16, 24 and 32 (corresponding to 8, 12 and 16 in the GUI), ST3.01/3.03 should only write 0, @@ -279,8 +282,11 @@ } break; case S3MFileHeader::trkImagoOrpheus: - madeWithTracker = U_("Imago Orpheus"); - formatTrackerStr = true; + formatTrackerStr = (fileHeader.cwtv != S3MFileHeader::trkPlayerPRO); + if(formatTrackerStr) + madeWithTracker = U_("Imago Orpheus"); + else + madeWithTracker = U_("PlayerPRO"); nonCompatTracker = true; break; case S3MFileHeader::trkImpulseTracker: Modified: branches/OpenMPT-1.31/soundlib/Load_ult.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Load_ult.cpp Sat May 11 09:36:53 2024 (r20757) +++ branches/OpenMPT-1.31/soundlib/Load_ult.cpp Sat May 11 17:30:11 2024 (r20758) @@ -18,7 +18,7 @@ { char signature[14]; // "MAS_UTrack_V00" uint8 version; // '1'...'4' - char songName[32]; // Song Name, not guaranteed to be null-terminated + char songName[32]; // Song Name, space-padded uint8 messageLength; // Number of Lines }; @@ -51,7 +51,7 @@ mptSmp.Initialize(); mptSmp.Set16BitCuePoints(); - mptSmp.filename = mpt::String::ReadBuf(mpt::String::maybeNullTerminated, filename); + mptSmp.filename = mpt::String::ReadBuf(mpt::String::spacePadded, filename); if(sizeEnd <= sizeStart) { @@ -385,7 +385,7 @@ } InitializeGlobals(MOD_TYPE_ULT); - m_songName = mpt::String::ReadBuf(mpt::String::maybeNullTerminated, fileHeader.songName); + m_songName = mpt::String::ReadBuf(mpt::String::spacePadded, fileHeader.songName); const mpt::uchar *versions[] = {UL_("<1.4"), UL_("1.4"), UL_("1.5"), UL_("1.6")}; m_modFormat.formatName = U_("UltraTracker"); @@ -419,7 +419,7 @@ } sampleHeader.ConvertToMPT(Samples[smp]); - m_szNames[smp] = mpt::String::ReadBuf(mpt::String::maybeNullTerminated, sampleHeader.name); + m_szNames[smp] = mpt::String::ReadBuf(mpt::String::spacePadded, sampleHeader.name); } ReadOrderFromFile<uint8>(Order(), file, 256, 0xFF, 0xFE); Modified: branches/OpenMPT-1.31/soundlib/S3MTools.h ============================================================================== --- branches/OpenMPT-1.31/soundlib/S3MTools.h Sat May 11 09:36:53 2024 (r20757) +++ branches/OpenMPT-1.31/soundlib/S3MTools.h Sat May 11 17:30:11 2024 (r20758) @@ -53,6 +53,7 @@ trkBeRoTrackerOld = 0x4100, // Used from 2004 to 2012 trkGraoumfTracker = 0x5447, trkCamoto = 0xCA00, + trkPlayerPRO = 0x2013 // PlayerPRO on Intel doesn't byte-swap the tracker ID bytes }; // Flags |
From: <sv...@op...> - 2024-05-11 07:37:05
|
Author: manx Date: Sat May 11 09:36:53 2024 New Revision: 20757 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20757 Log: [Ref] mpt/random/device.hpp: Remove redundant state. Modified: trunk/OpenMPT/src/mpt/random/device.hpp Modified: trunk/OpenMPT/src/mpt/random/device.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/random/device.hpp Fri May 10 22:43:12 2024 (r20756) +++ trunk/OpenMPT/src/mpt/random/device.hpp Sat May 11 09:36:53 2024 (r20757) @@ -128,7 +128,6 @@ std::string token; #if !defined(MPT_COMPILER_QUIRK_RANDOM_NO_RANDOM_DEVICE) std::unique_ptr<std::random_device> prd; - bool rd_reliable{false}; #endif // !MPT_COMPILER_QUIRK_RANDOM_NO_RANDOM_DEVICE std::unique_ptr<std::mt19937> rd_fallback; @@ -164,13 +163,12 @@ #if !defined(MPT_COMPILER_QUIRK_RANDOM_NO_RANDOM_DEVICE) try { prd = std::make_unique<std::random_device>(); - rd_reliable = ((*prd).entropy() > 0.0); + if (!((*prd).entropy() > 0.0)) { + init_fallback(); + } } catch (mpt::out_of_memory e) { mpt::rethrow_out_of_memory(e); } catch (const std::exception &) { - rd_reliable = false; - } - if (!rd_reliable) { init_fallback(); } #else // MPT_COMPILER_QUIRK_RANDOM_NO_RANDOM_DEVICE @@ -182,13 +180,12 @@ #if !defined(MPT_COMPILER_QUIRK_RANDOM_NO_RANDOM_DEVICE) try { prd = std::make_unique<std::random_device>(token); - rd_reliable = ((*prd).entropy() > 0.0); + if (!((*prd).entropy() > 0.0)) { + init_fallback(); + } } catch (mpt::out_of_memory e) { mpt::rethrow_out_of_memory(e); } catch (const std::exception &) { - rd_reliable = false; - } - if (!rd_reliable) { init_fallback(); } #else // MPT_COMPILER_QUIRK_RANDOM_NO_RANDOM_DEVICE @@ -239,13 +236,10 @@ } } } catch (const std::exception &) { - rd_reliable = false; init_fallback(); } - } else { - rd_reliable = false; } - if (!rd_reliable) { + if (rd_fallback) { // std::random_device is unreliable // XOR the generated random number with more entropy from the time-seeded // PRNG. |
From: <sv...@op...> - 2024-05-10 20:43:24
|
Author: sagamusix Date: Fri May 10 22:43:12 2024 New Revision: 20756 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20756 Log: Merged revision(s) 20749-20750, 20755 from trunk/OpenMPT: [Mod] Reduce static variable usage in fuzzer program to eventually allow using __AFL_LOOP. ........ [Imp] mptRandom: Add reinit_global_random() function for fuzzer builds to allow deterministic consecutive fuzzer runs in the same process. ........ [Imp] Speed up fuzzing by using persistent mode and shared memory file input. Note: afl++ will report a stability of about 99.x%. According to its debug output, the unstable edges are in WavesReverb and I3DL2Reverb implementations, however the unstable edges that it finds don't make any sense. As a tiny bit of instability in these parts of the code should not hurt overall code coverage, we trade this for the significant gains in speed that persistent mode gives us. ........ Added: branches/OpenMPT-1.31/contrib/fuzzing/fuzz.cpp - copied unchanged from r20755, trunk/OpenMPT/contrib/fuzzing/fuzz.cpp Deleted: branches/OpenMPT-1.31/contrib/fuzzing/fuzz.c Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/Makefile branches/OpenMPT-1.31/common/mptRandom.cpp branches/OpenMPT-1.31/common/mptRandom.h Modified: branches/OpenMPT-1.31/Makefile ============================================================================== --- branches/OpenMPT-1.31/Makefile Fri May 10 21:11:37 2024 (r20755) +++ branches/OpenMPT-1.31/Makefile Fri May 10 22:43:12 2024 (r20756) @@ -2012,10 +2012,10 @@ endif endif -contrib/fuzzing/fuzz$(FLAVOUR_O).o: contrib/fuzzing/fuzz.c - $(INFO) [CC] $< - $(VERYSILENT)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -M -MT$@ $< > $*$(FLAVOUR_O).d - $(SILENT)$(COMPILE.c) $(OUTPUT_OPTION) $< +contrib/fuzzing/fuzz$(FLAVOUR_O).o: contrib/fuzzing/fuzz.cpp + $(INFO) [CXX] $< + $(VERYSILENT)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -M -MT$@ $< > $*$(FLAVOUR_O).d + $(SILENT)$(COMPILE.cc) $(OUTPUT_OPTION) $< bin/$(FLAVOUR_DIR)fuzz$(EXESUFFIX): contrib/fuzzing/fuzz$(FLAVOUR_O).o $(OBJECTS_LIBOPENMPT) $(OUTPUT_LIBOPENMPT) $(INFO) [LD] $@ $(SILENT)$(LINK.cc) $(LDFLAGS_LIBOPENMPT) contrib/fuzzing/fuzz$(FLAVOUR_O).o $(OBJECTS_LIBOPENMPT) $(LOADLIBES) $(LDLIBS) $(LDLIBS_LIBOPENMPT) -o $@ Modified: branches/OpenMPT-1.31/common/mptRandom.cpp ============================================================================== --- branches/OpenMPT-1.31/common/mptRandom.cpp Fri May 10 21:11:37 2024 (r20755) +++ branches/OpenMPT-1.31/common/mptRandom.cpp Fri May 10 22:43:12 2024 (r20756) @@ -55,6 +55,16 @@ return g_global_prng; } +#ifdef MPT_BUILD_FUZZER +void reinit_global_random() +{ + global_prng().~thread_safe_prng<mpt::default_prng>(); + global_random_device().~random_device(); + new(&global_random_device()) mpt::random_device{}; + new(&global_prng()) thread_safe_prng<mpt::default_prng>{global_random_device()}; +} +#endif // MPT_BUILD_FUZZER + #endif // MODPLUG_TRACKER && !MPT_BUILD_WINESUPPORT } // namespace mpt Modified: branches/OpenMPT-1.31/common/mptRandom.h ============================================================================== --- branches/OpenMPT-1.31/common/mptRandom.h Fri May 10 21:11:37 2024 (r20755) +++ branches/OpenMPT-1.31/common/mptRandom.h Fri May 10 22:43:12 2024 (r20756) @@ -128,6 +128,10 @@ mpt::random_device & global_random_device(); mpt::thread_safe_prng<mpt::default_prng> & global_prng(); +#ifdef MPT_BUILD_FUZZER +void reinit_global_random(); +#endif // MPT_BUILD_FUZZER + #if defined(MODPLUG_TRACKER) && !defined(MPT_BUILD_WINESUPPORT) void set_global_random_device(mpt::random_device *rd); void set_global_prng(mpt::thread_safe_prng<mpt::default_prng> *rng); Copied: branches/OpenMPT-1.31/contrib/fuzzing/fuzz.cpp (from r20755, trunk/OpenMPT/contrib/fuzzing/fuzz.cpp) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/OpenMPT-1.31/contrib/fuzzing/fuzz.cpp Fri May 10 22:43:12 2024 (r20756, copy of r20755, trunk/OpenMPT/contrib/fuzzing/fuzz.cpp) @@ -0,0 +1,88 @@ +/* + * fuzz.cpp + * -------- + * Purpose: Tiny libopenmpt user to be used by fuzzing tools + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#include <memory> +#include <cstdint> +#include <cstdlib> + +#include <cerrno> +#include <unistd.h> + +#include <libopenmpt/libopenmpt.h> + +#include "../../common/mptRandom.h" + +#define BUFFERSIZE 450 // shouldn't match OpenMPT's internal mix buffer size (512) +#define SAMPLERATE 22050 + +static int16_t buffer[BUFFERSIZE]; + +static int ErrFunc (int error, void *) +{ + switch (error) + { + case OPENMPT_ERROR_INVALID_ARGUMENT: + case OPENMPT_ERROR_OUT_OF_RANGE: + case OPENMPT_ERROR_LENGTH: + case OPENMPT_ERROR_DOMAIN: + case OPENMPT_ERROR_LOGIC: + case OPENMPT_ERROR_UNDERFLOW: + case OPENMPT_ERROR_OVERFLOW: + case OPENMPT_ERROR_RANGE: + case OPENMPT_ERROR_RUNTIME: + case OPENMPT_ERROR_EXCEPTION: + std::abort(); + default: + return OPENMPT_ERROR_FUNC_RESULT_NONE; + } +} + +__AFL_FUZZ_INIT(); + +int main( int argc, char * argv[] ) { + (void)argc; + (void)argv; + openmpt_module_create_from_memory2( buffer, BUFFERSIZE, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr ); +#ifdef __AFL_HAVE_MANUAL_CONTROL + __AFL_INIT(); +#endif + + unsigned char *fileBuffer = __AFL_FUZZ_TESTCASE_BUF; // must be after __AFL_INIT and before __AFL_LOOP! + + while (__AFL_LOOP(10000)) { + int fileSize = __AFL_FUZZ_TESTCASE_LEN; + 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; + + // 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 ) + std::abort(); + + openmpt_module_ctl_set( mod, "render.resampler.emulate_amiga", (openmpt_module_get_num_orders( mod ) & 1) ? "0" : "1" ); + // render about a second of the module for fuzzing the actual mix routines + for(int i = 0; i < 50; i++) { + size_t count = openmpt_module_read_mono( mod, SAMPLERATE, BUFFERSIZE, buffer ); + if ( count == 0 ) { + break; + } + } + openmpt_module_set_position_seconds( mod, 1.0 ); + openmpt_module_read_mono( mod, SAMPLERATE, BUFFERSIZE, buffer ); + openmpt_module_set_position_order_row( mod, 3, 16 ); + openmpt_module_read_mono( mod, SAMPLERATE, BUFFERSIZE, buffer ); + + // fuzz string-related stuff + openmpt_free_string ( openmpt_module_get_metadata( mod, "date" ) ); + openmpt_free_string ( openmpt_module_get_metadata( mod, "message" ) ); + openmpt_module_destroy( mod ); + } + return 0; +} |