From e4c74aab8bf7d59a45021ba58d0cbfd657ff8b4d Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 6 Jan 2024 03:38:35 +0100 Subject: [PATCH] rbuilt with debug package, -tools subpackage and patches taken from Arch Linux [release 1.2.12-2mamba;Tue Feb 08 2022] --- libSDL_mixer-1.2.12-double-free-crash.patch | 32 +++++++++ ...xer-1.2.12-fluidsynth-use-after-free.patch | 37 ++++++++++ libSDL_mixer-1.2.12-fluidsynth-volume.patch | 23 +++++++ libSDL_mixer-1.2.12-mikmod1.patch | 67 +++++++++++++++++++ libSDL_mixer-1.2.12-mikmod2.patch | 35 ++++++++++ libSDL_mixer.spec | 52 +++++++++++--- 6 files changed, 235 insertions(+), 11 deletions(-) create mode 100644 libSDL_mixer-1.2.12-double-free-crash.patch create mode 100644 libSDL_mixer-1.2.12-fluidsynth-use-after-free.patch create mode 100644 libSDL_mixer-1.2.12-fluidsynth-volume.patch create mode 100644 libSDL_mixer-1.2.12-mikmod1.patch create mode 100644 libSDL_mixer-1.2.12-mikmod2.patch diff --git a/libSDL_mixer-1.2.12-double-free-crash.patch b/libSDL_mixer-1.2.12-double-free-crash.patch new file mode 100644 index 0000000..6f4e6a1 --- /dev/null +++ b/libSDL_mixer-1.2.12-double-free-crash.patch @@ -0,0 +1,32 @@ + +# HG changeset patch +# User Sam Lantinga +# Date 1329087437 18000 +# Node ID 2d713670db9b832b0c5aa700824900bc1fc3c3cd +# Parent df72f22b4b411ad4b08f924329678aabd5ac97d6 +Fixed 1418 - crash on double free if loading WAV file failed + +diff -r df72f22b4b41 -r 2d713670db9b mixer.c +--- a/mixer.c Mon Jan 30 21:41:45 2012 -0500 ++++ b/mixer.c Sun Feb 12 17:57:17 2012 -0500 +@@ -610,13 +610,15 @@ + break; + default: + SDL_SetError("Unrecognized sound file type"); +- return(0); ++ if ( freesrc ) { ++ SDL_RWclose(src); ++ } ++ loaded = NULL; ++ break; + } + if ( !loaded ) { ++ /* The individual loaders have closed src if needed */ + SDL_free(chunk); +- if ( freesrc ) { +- SDL_RWclose(src); +- } + return(NULL); + } + + diff --git a/libSDL_mixer-1.2.12-fluidsynth-use-after-free.patch b/libSDL_mixer-1.2.12-fluidsynth-use-after-free.patch new file mode 100644 index 0000000..c13e62a --- /dev/null +++ b/libSDL_mixer-1.2.12-fluidsynth-use-after-free.patch @@ -0,0 +1,37 @@ +From 452a55c5d8cd78621114b8aaa258377403797ea7 Mon Sep 17 00:00:00 2001 +From: Ozkan Sezer +Date: Fri, 22 Jan 2021 17:47:01 +0300 +Subject: [PATCH] Fix use-after-free in music_fluidsynth.c (backport from + default branch) + +Tom M. + +There is a dangerous use-after-free in FLUIDSYNTH_Delete(): the settings +object is deleted **before** the synth. Since the settings have been +created first to initialize the synth, you must first delete the synth +and then delete the settings. This currently crashes all applications +that use fluidsynth 2.1.6 and SDL2_mixer. + +Originally reported at https://github.com/FluidSynth/fluidsynth/issues/748 +--- + fluidsynth.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/fluidsynth.c b/fluidsynth.c +index 717d8aa..179d79c 100644 +--- a/fluidsynth.c ++++ b/fluidsynth.c +@@ -152,10 +152,12 @@ FluidSynthMidiSong *fluidsynth_loadsong_RW(SDL_RWops *rw, int freerw) + + void fluidsynth_freesong(FluidSynthMidiSong *song) + { ++ fluid_settings_t *settings; + if (!song) return; ++ settings = fluidsynth.fluid_synth_get_settings(song->synth); + fluidsynth.delete_fluid_player(song->player); +- fluidsynth.delete_fluid_settings(fluidsynth.fluid_synth_get_settings(song->synth)); + fluidsynth.delete_fluid_synth(song->synth); ++ fluidsynth.delete_fluid_settings(settings); + SDL_free(song); + } + diff --git a/libSDL_mixer-1.2.12-fluidsynth-volume.patch b/libSDL_mixer-1.2.12-fluidsynth-volume.patch new file mode 100644 index 0000000..cf346ed --- /dev/null +++ b/libSDL_mixer-1.2.12-fluidsynth-volume.patch @@ -0,0 +1,23 @@ + +# HG changeset patch +# User James Le Cuirot +# Date 1330896767 0 +# Node ID c92001a2c18f628698c58aa4e05a7335d10d0e9e +# Parent 2d713670db9b832b0c5aa700824900bc1fc3c3cd +Raise the maximum FluidSynth gain from 0.8 to 1.2 because apparently the former is too quiet in some cases. + +diff -r 2d713670db9b -r c92001a2c18f fluidsynth.c +--- a/fluidsynth.c Sun Feb 12 17:57:17 2012 -0500 ++++ b/fluidsynth.c Sun Mar 04 21:32:47 2012 +0000 +@@ -176,8 +176,8 @@ + + void fluidsynth_setvolume(FluidSynthMidiSong *song, int volume) + { +- /* FluidSynth's default is 0.2. Make 0.8 the maximum. */ +- fluidsynth.fluid_synth_set_gain(song->synth, (float) (volume * 0.00625)); ++ /* FluidSynth's default is 0.2. Make 1.2 the maximum. */ ++ fluidsynth.fluid_synth_set_gain(song->synth, (float) (volume * 1.2 / MIX_MAX_VOLUME)); + } + + int fluidsynth_playsome(FluidSynthMidiSong *song, void *dest, int dest_len) + diff --git a/libSDL_mixer-1.2.12-mikmod1.patch b/libSDL_mixer-1.2.12-mikmod1.patch new file mode 100644 index 0000000..b3bb829 --- /dev/null +++ b/libSDL_mixer-1.2.12-mikmod1.patch @@ -0,0 +1,67 @@ + +# HG changeset patch +# User Sam Lantinga +# Date 1342998807 25200 +# Node ID 56cad6484b04f83c8d42428c755a046678506436 +# Parent c92001a2c18f628698c58aa4e05a7335d10d0e9e +Paul P Komkoff Jr fixed malloc/free mismatch in the MikMod driver + +diff -r c92001a2c18f -r 56cad6484b04 CHANGES +--- a/CHANGES Sun Mar 04 21:32:47 2012 +0000 ++++ b/CHANGES Sun Jul 22 16:13:27 2012 -0700 +@@ -1,3 +1,7 @@ ++1.2.13: ++Paul P Komkoff Jr - Sun Jul 22 16:12:28 PDT 2012 ++ * Fixed malloc/free mismatch in the MikMod driver ++ + 1.2.12: + Sam Lantinga - Sat Jan 14 22:00:29 2012 -0500 + * Fixed seek offset with SMPEG (was relative, should be absolute) +diff -r c92001a2c18f -r 56cad6484b04 dynamic_mod.c +--- a/dynamic_mod.c Sun Mar 04 21:32:47 2012 +0000 ++++ b/dynamic_mod.c Sun Jul 22 16:13:27 2012 -0700 +@@ -93,6 +93,13 @@ + SDL_UnloadObject(mikmod.handle); + return -1; + } ++ mikmod.MikMod_free = ++ (void (*)(void*)) ++ SDL_LoadFunction(mikmod.handle, "MikMod_free"); ++ if ( mikmod.MikMod_free == NULL ) { ++ SDL_UnloadObject(mikmod.handle); ++ return -1; ++ } + mikmod.Player_Active = + (BOOL (*)(void)) + SDL_LoadFunction(mikmod.handle, "Player_Active"); +diff -r c92001a2c18f -r 56cad6484b04 dynamic_mod.h +--- a/dynamic_mod.h Sun Mar 04 21:32:47 2012 +0000 ++++ b/dynamic_mod.h Sun Jul 22 16:13:27 2012 -0700 +@@ -35,6 +35,7 @@ + void (*MikMod_RegisterDriver)(struct MDRIVER*); + int* MikMod_errno; + char* (*MikMod_strerror)(int); ++ void (*MikMod_free)(void*); + BOOL (*Player_Active)(void); + void (*Player_Free)(MODULE*); + MODULE* (*Player_LoadGeneric)(MREADER*,int,BOOL); +diff -r c92001a2c18f -r 56cad6484b04 music_mod.c +--- a/music_mod.c Sun Mar 04 21:32:47 2012 +0000 ++++ b/music_mod.c Sun Jul 22 16:13:27 2012 -0700 +@@ -109,13 +109,13 @@ + + list = mikmod.MikMod_InfoDriver(); + if ( list ) +- free(list); ++ mikmod.MikMod_free(list); + else + mikmod.MikMod_RegisterDriver(mikmod.drv_nos); + + list = mikmod.MikMod_InfoLoader(); + if ( list ) +- free(list); ++ mikmod.MikMod_free(list); + else + mikmod.MikMod_RegisterAllLoaders(); + + diff --git a/libSDL_mixer-1.2.12-mikmod2.patch b/libSDL_mixer-1.2.12-mikmod2.patch new file mode 100644 index 0000000..6e89ca8 --- /dev/null +++ b/libSDL_mixer-1.2.12-mikmod2.patch @@ -0,0 +1,35 @@ + +# HG changeset patch +# User Sam Lantinga +# Date 1343000017 25200 +# Node ID 2ebb0d016f277f7f643d8a66ed0e1099e10d1fba +# Parent 56cad6484b04f83c8d42428c755a046678506436 +Fixed normal linking with libmikmod and linking with earlier versions of libmikmod. + +diff -r 56cad6484b04 -r 2ebb0d016f27 dynamic_mod.c +--- a/dynamic_mod.c Sun Jul 22 16:13:27 2012 -0700 ++++ b/dynamic_mod.c Sun Jul 22 16:33:37 2012 -0700 +@@ -97,8 +97,8 @@ + (void (*)(void*)) + SDL_LoadFunction(mikmod.handle, "MikMod_free"); + if ( mikmod.MikMod_free == NULL ) { +- SDL_UnloadObject(mikmod.handle); +- return -1; ++ /* libmikmod 3.1 and earlier doesn't have it */ ++ mikmod.MikMod_free = free; + } + mikmod.Player_Active = + (BOOL (*)(void)) +@@ -246,6 +246,11 @@ + mikmod.MikMod_RegisterDriver = MikMod_RegisterDriver; + mikmod.MikMod_errno = &MikMod_errno; + mikmod.MikMod_strerror = MikMod_strerror; ++#if LIBMIKMOD_VERSION < ((3<<16)|(2<<8)) ++ mikmod.MikMod_free = free; ++#else ++ mikmod.MikMod_free = MikMod_free; ++#endif + mikmod.Player_Active = Player_Active; + mikmod.Player_Free = Player_Free; + mikmod.Player_LoadGeneric = Player_LoadGeneric; + diff --git a/libSDL_mixer.spec b/libSDL_mixer.spec index 751869e..3149056 100644 --- a/libSDL_mixer.spec +++ b/libSDL_mixer.spec @@ -1,24 +1,30 @@ Name: libSDL_mixer Version: 1.2.12 -Release: 1mamba +Release: 2mamba Summary: SDL_mixer is a sample multi-channel audio mixer library Group: System/Libraries Vendor: openmamba Distribution: openmamba Packager: Silvan Calarco -URL: http://www.libsdl.org/projects/SDL_mixer/ -Source: http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-%{version}.tar.gz +URL: https://www.libsdl.org/projects/SDL_mixer/ +Source: https://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-%{version}.tar.gz +Patch0: libSDL_mixer-1.2.12-double-free-crash.patch +Patch1: libSDL_mixer-1.2.12-fluidsynth-use-after-free.patch +Patch2: libSDL_mixer-1.2.12-fluidsynth-volume.patch +Patch3: libSDL_mixer-1.2.12-mikmod1.patch +Patch4: libSDL_mixer-1.2.12-mikmod2.patch License: LGPL ## AUTOBUILDREQ-BEGIN BuildRequires: glibc-devel -BuildRequires: libdirectfb-devel BuildRequires: libSDL-devel +BuildRequires: libdirectfb-devel +BuildRequires: libstdc++6-devel +BuildRequires: libts-devel BuildRequires: libz-devel ## AUTOBUILDREQ-END BuildRequires: libvorbis-devel BuildRequires: libsmpeg-devel BuildRequires: libmikmod-devel -BuildRoot: %{_tmppath}/%{name}-%{version}-root %description SDL_mixer is a sample multi-channel audio mixer library. @@ -32,14 +38,32 @@ Requires: %{name} = %{?epoch:%epoch:}%{version}-%{release} %description devel SDL_mixer is a sample multi-channel audio mixer library. It supports any number of simultaneously playing channels of 16 bit stereo audio, plus a single channel of music, mixed by the popular MikMod MOD, Timidity MIDI, Ogg Vorbis, and SMPEG MP3 libraries. +This package contains static libraries and header files needed for development. -This package contains static libraries and header files need for development. +%package tools +Group: Applications/Multimedia +Summary: Tools provided with %{name} +Requires: %{name} = %{?epoch:%epoch:}%{version}-%{release} + +%description tools +SDL_mixer is a sample multi-channel audio mixer library. +It supports any number of simultaneously playing channels of 16 bit stereo audio, plus a single channel of music, mixed by the popular MikMod MOD, Timidity MIDI, Ogg Vorbis, and SMPEG MP3 libraries. +This package contains static the tools provided with %{name}. + +%debug_package %prep %setup -q -n SDL_mixer-%{version} +%patch0 -p1 -b .double-free-crash +%patch1 -p1 -b .fluidsynth-use-after-free +%patch2 -p1 -b .fluidsynth-volume +%patch3 -p1 -b .mikmod1 +%patch4 -p1 -b .mikmod2 +sed -i "s,| arm-\* |,| aarch64-\* | arm-\* |," build-scripts/config.sub %build -%configure --disable-smpegtest +%configure +#--disable-smpegtest %make LDFLAGS=-lm %install @@ -54,21 +78,27 @@ This package contains static libraries and header files need for development. %files %defattr(-,root,root) -%{_bindir}/playmus -%{_bindir}/playwave %{_libdir}/libSDL_mixer*.so.* -%doc CHANGES COPYING README +%doc COPYING %files devel %defattr(-,root,root) -%dir %{_includedir}/SDL %{_includedir}/SDL/*.h %{_libdir}/libSDL_mixer.a %{_libdir}/libSDL_mixer.la %{_libdir}/libSDL_mixer.so %{_libdir}/pkgconfig/SDL_mixer.pc +%doc CHANGES README + +%files tools +%defattr(-,root,root) +%{_bindir}/playmus +%{_bindir}/playwave %changelog +* Tue Feb 08 2022 Silvan Calarco 1.2.12-2mamba +- rbuilt with debug package, -tools subpackage and patches taken from Arch Linux + * Mon Jan 23 2012 Automatic Build System 1.2.12-1mamba - automatic version update by autodist