Gentoo Archives: gentoo-commits

From: James Le Cuirot <chewi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: media-libs/sdl2-mixer/, media-libs/sdl2-mixer/files/
Date: Sun, 05 Sep 2021 17:09:27
Message-Id: 1630861750.66b0c1ea58b968df55f721e6af3046a6901caa59.chewi@gentoo
1 commit: 66b0c1ea58b968df55f721e6af3046a6901caa59
2 Author: James Le Cuirot <chewi <AT> gentoo <DOT> org>
3 AuthorDate: Sun Sep 5 17:08:20 2021 +0000
4 Commit: James Le Cuirot <chewi <AT> gentoo <DOT> org>
5 CommitDate: Sun Sep 5 17:09:10 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=66b0c1ea
7
8 media-libs/sdl2-mixer: Backport patch to fix FluidSynth memory issue
9
10 Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>
11
12 .../files/sdl2-mixer-2.0.4-fluidsynth.patch | 30 +++++
13 media-libs/sdl2-mixer/sdl2-mixer-2.0.4-r1.ebuild | 125 +++++++++++++++++++++
14 2 files changed, 155 insertions(+)
15
16 diff --git a/media-libs/sdl2-mixer/files/sdl2-mixer-2.0.4-fluidsynth.patch b/media-libs/sdl2-mixer/files/sdl2-mixer-2.0.4-fluidsynth.patch
17 new file mode 100644
18 index 00000000000..cd740ac85c1
19 --- /dev/null
20 +++ b/media-libs/sdl2-mixer/files/sdl2-mixer-2.0.4-fluidsynth.patch
21 @@ -0,0 +1,30 @@
22 +From 6160668079f91d57a5d7bf0b40ffdd843be70daf Mon Sep 17 00:00:00 2001
23 +From: Sam Lantinga <slouken@××××××.org>
24 +Date: Wed, 20 Jan 2021 10:17:10 -0800
25 +Subject: [PATCH] Fixed use-after-free in music_fluidsynth.c
26 +
27 +Tom M.
28 +
29 +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. Please apply the attached patch and release a bug fix release.
30 +
31 +Originally reported at https://github.com/FluidSynth/fluidsynth/issues/748
32 +---
33 + src/codecs/music_fluidsynth.c | 3 ++-
34 + 1 file changed, 2 insertions(+), 1 deletion(-)
35 +
36 +diff --git a/src/codecs/music_fluidsynth.c b/src/codecs/music_fluidsynth.c
37 +index 8667f0d9..a47247f4 100644
38 +--- a/music_fluidsynth.c
39 ++++ b/music_fluidsynth.c
40 +@@ -285,9 +285,10 @@ static void FLUIDSYNTH_Stop(void *context)
41 + static void FLUIDSYNTH_Delete(void *context)
42 + {
43 + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context;
44 ++ fluid_settings_t *settings = fluidsynth.fluid_synth_get_settings(music->synth);
45 + fluidsynth.delete_fluid_player(music->player);
46 +- fluidsynth.delete_fluid_settings(fluidsynth.fluid_synth_get_settings(music->synth));
47 + fluidsynth.delete_fluid_synth(music->synth);
48 ++ fluidsynth.delete_fluid_settings(settings);
49 + SDL_free(music);
50 + }
51 +
52
53 diff --git a/media-libs/sdl2-mixer/sdl2-mixer-2.0.4-r1.ebuild b/media-libs/sdl2-mixer/sdl2-mixer-2.0.4-r1.ebuild
54 new file mode 100644
55 index 00000000000..dcbbcee2dae
56 --- /dev/null
57 +++ b/media-libs/sdl2-mixer/sdl2-mixer-2.0.4-r1.ebuild
58 @@ -0,0 +1,125 @@
59 +# Copyright 1999-2021 Gentoo Authors
60 +# Distributed under the terms of the GNU General Public License v2
61 +
62 +EAPI=7
63 +
64 +MY_P="SDL2_mixer-${PV}"
65 +inherit autotools multilib-minimal
66 +
67 +DESCRIPTION="Simple Direct Media Layer Mixer Library"
68 +HOMEPAGE="https://www.libsdl.org/projects/SDL_mixer/"
69 +SRC_URI="https://www.libsdl.org/projects/SDL_mixer/release/${MY_P}.tar.gz"
70 +
71 +LICENSE="ZLIB"
72 +SLOT="0"
73 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86"
74 +IUSE="flac fluidsynth mad midi mikmod mod modplug mp3 opus playtools static-libs timidity tremor vorbis +wav"
75 +REQUIRED_USE="
76 + midi? ( || ( timidity fluidsynth ) )
77 + timidity? ( midi )
78 + fluidsynth? ( midi )
79 + mad? ( mp3 )
80 + mod? ( || ( mikmod modplug ) )
81 + mikmod? ( mod )
82 + modplug? ( mod )
83 + tremor? ( vorbis )
84 +"
85 +
86 +RDEPEND="
87 + >=media-libs/libsdl2-2.0.7[${MULTILIB_USEDEP}]
88 + flac? ( >=media-libs/flac-1.2.1-r5[${MULTILIB_USEDEP}] )
89 + midi? (
90 + fluidsynth? ( >=media-sound/fluidsynth-1.1.6-r1:=[${MULTILIB_USEDEP}] )
91 + timidity? ( media-sound/timidity++ )
92 + )
93 + mod? (
94 + mikmod? ( >=media-libs/libmikmod-3.3.6-r1[${MULTILIB_USEDEP}] )
95 + modplug? ( >=media-libs/libmodplug-0.8.8.4-r1[${MULTILIB_USEDEP}] )
96 + )
97 + mp3? (
98 + mad? ( >=media-libs/libmad-0.15.1b-r8[${MULTILIB_USEDEP}] )
99 + !mad? ( media-sound/mpg123[${MULTILIB_USEDEP}] )
100 + )
101 + opus? ( >=media-libs/opusfile-0.2 )
102 + vorbis? (
103 + tremor? ( >=media-libs/tremor-0_pre20130223[${MULTILIB_USEDEP}] )
104 + !tremor? (
105 + >=media-libs/libvorbis-1.3.3-r1[${MULTILIB_USEDEP}]
106 + >=media-libs/libogg-1.3.0[${MULTILIB_USEDEP}] )
107 + )
108 +"
109 +DEPEND="${RDEPEND}"
110 +
111 +S="${WORKDIR}/${MY_P}"
112 +
113 +PATCHES=(
114 + "${FILESDIR}/${PN}-2.0.4-slibtool.patch"
115 + "${FILESDIR}/${PN}-2.0.4-fluidsynth.patch"
116 +)
117 +
118 +src_prepare() {
119 + default
120 +
121 + # for slibtool patch in 2.0.4, can drop in future with eautoreconf
122 + rm aclocal.m4 || die
123 + eautoreconf
124 + multilib_copy_sources
125 +}
126 +
127 +multilib_src_configure() {
128 + local myeconfargs=(
129 + $(use_enable static-libs static)
130 + --disable-sdltest
131 + --enable-music-cmd
132 + $(use_enable wav music-wave)
133 + $(use_enable mod music-mod)
134 + $(use_enable modplug music-mod-modplug)
135 + --disable-music-mod-modplug-shared
136 + $(use_enable mikmod music-mod-mikmod)
137 + --disable-music-mod-mikmod-shared
138 + $(use_enable midi music-midi)
139 + $(use_enable timidity music-midi-timidity)
140 + $(use_enable fluidsynth music-midi-fluidsynth)
141 + --disable-music-midi-fluidsynth-shared
142 + $(use_enable vorbis music-ogg)
143 + $(use_enable tremor music-ogg-tremor)
144 + --disable-music-ogg-shared
145 + $(use_enable flac music-flac)
146 + --disable-music-flac-shared
147 + $(use_enable mp3 music-mp3)
148 + $(use_enable !mad music-mp3-mpg123)
149 + --disable-music-mp3-mpg123-shared
150 + $(use_enable mad music-mp3-mad-gpl)
151 + $(use_enable opus music-opus)
152 + --disable-music-opus-shared
153 + LIBMIKMOD_CONFIG=${EPREFIX}/usr/bin/${CHOST}-libmikmod-config
154 + )
155 + ECONF_SOURCE=${S} econf "${myeconfargs[@]}"
156 +}
157 +
158 +multilib_src_install() {
159 + emake DESTDIR="${D}" install
160 + if multilib_is_native_abi && use playtools ; then
161 + emake DESTDIR="${D}" install-bin
162 + fi
163 +}
164 +
165 +multilib_src_install_all() {
166 + dodoc {CHANGES,README}.txt
167 + find "${D}" -name '*.la' -delete || die
168 +}
169 +
170 +pkg_postinst() {
171 + # bug 412035
172 + # https://bugs.gentoo.org/show_bug.cgi?id=412035
173 + if use midi && use fluidsynth; then
174 + ewarn "FluidSynth support requires you to set the SDL_SOUNDFONTS"
175 + ewarn "environment variable to the location of a SoundFont file"
176 + ewarn "unless the game or application happens to do this for you."
177 + if use timidity; then
178 + ewarn "Failing to do so will result in Timidity being used instead."
179 + else
180 + ewarn "Failing to do so will result in silence."
181 + fi
182 + fi
183 +}