Gentoo Archives: gentoo-commits

From: Andreas Sturmlechner <asturm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: media-libs/libsndfile/files/, media-libs/libsndfile/
Date: Wed, 03 Oct 2018 19:22:54
Message-Id: 1538594525.b8fc21b710b18e21dfba9506f666ec18744a3e64.asturm@gentoo
1 commit: b8fc21b710b18e21dfba9506f666ec18744a3e64
2 Author: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
3 AuthorDate: Wed Oct 3 19:16:17 2018 +0000
4 Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
5 CommitDate: Wed Oct 3 19:22:05 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b8fc21b7
7
8 media-libs/libsndfile: Fix multiple vulnerabilities
9
10 Bug: https://bugs.gentoo.org/618016
11 Bug: https://bugs.gentoo.org/631634
12 Bug: https://bugs.gentoo.org/624814
13 Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>
14 Package-Manager: Portage-2.3.50, Repoman-2.3.11
15
16 .../files/libsndfile-1.0.28-CVE-2017-14634.patch | 35 +++++++++++
17 .../files/libsndfile-1.0.28-CVE-2017-6892.patch | 25 ++++++++
18 .../files/libsndfile-1.0.28-CVE-2017-8362.patch | 50 ++++++++++++++++
19 .../files/libsndfile-1.0.28-CVE-2017-8363.patch | 28 +++++++++
20 .../files/libsndfile-1.0.28-CVE-2017-8365.patch | 64 ++++++++++++++++++++
21 .../files/libsndfile-1.0.28-CVE-2018-13139.patch | 2 +-
22 media-libs/libsndfile/libsndfile-1.0.28-r4.ebuild | 70 ++++++++++++++++++++++
23 7 files changed, 273 insertions(+), 1 deletion(-)
24
25 diff --git a/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2017-14634.patch b/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2017-14634.patch
26 new file mode 100644
27 index 00000000000..9eab370aac4
28 --- /dev/null
29 +++ b/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2017-14634.patch
30 @@ -0,0 +1,35 @@
31 +From 85c877d5072866aadbe8ed0c3e0590fbb5e16788 Mon Sep 17 00:00:00 2001
32 +From: Fabian Greffrath <fabian@×××××××××.com>
33 +Date: Thu, 28 Sep 2017 12:15:04 +0200
34 +Subject: [PATCH] double64_init: Check psf->sf.channels against upper bound
35 +
36 +This prevents division by zero later in the code.
37 +
38 +While the trivial case to catch this (i.e. sf.channels < 1) has already
39 +been covered, a crafted file may report a number of channels that is
40 +so high (i.e. > INT_MAX/sizeof(double)) that it "somehow" gets
41 +miscalculated to zero (if this makes sense) in the determination of the
42 +blockwidth. Since we only support a limited number of channels anyway,
43 +make sure to check here as well.
44 +
45 +CVE-2017-14634
46 +
47 +Closes: https://github.com/erikd/libsndfile/issues/318
48 +Signed-off-by: Erik de Castro Lopo <erikd@×××××××××.com>
49 +---
50 + src/double64.c | 2 +-
51 + 1 file changed, 1 insertion(+), 1 deletion(-)
52 +
53 +diff --git a/src/double64.c b/src/double64.c
54 +index b318ea86..78dfef7f 100644
55 +--- a/src/double64.c
56 ++++ b/src/double64.c
57 +@@ -91,7 +91,7 @@ int
58 + double64_init (SF_PRIVATE *psf)
59 + { static int double64_caps ;
60 +
61 +- if (psf->sf.channels < 1)
62 ++ if (psf->sf.channels < 1 || psf->sf.channels > SF_MAX_CHANNELS)
63 + { psf_log_printf (psf, "double64_init : internal error : channels = %d\n", psf->sf.channels) ;
64 + return SFE_INTERNAL ;
65 + } ;
66
67 diff --git a/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2017-6892.patch b/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2017-6892.patch
68 new file mode 100644
69 index 00000000000..d5ccf726684
70 --- /dev/null
71 +++ b/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2017-6892.patch
72 @@ -0,0 +1,25 @@
73 +From f833c53cb596e9e1792949f762e0b33661822748 Mon Sep 17 00:00:00 2001
74 +From: Erik de Castro Lopo <erikd@×××××××××.com>
75 +Date: Tue, 23 May 2017 20:15:24 +1000
76 +Subject: [PATCH] src/aiff.c: Fix a buffer read overflow
77 +
78 +Secunia Advisory SA76717.
79 +
80 +Found by: Laurent Delosieres, Secunia Research at Flexera Software
81 +---
82 + src/aiff.c | 2 +-
83 + 1 file changed, 1 insertion(+), 1 deletion(-)
84 +
85 +diff --git a/src/aiff.c b/src/aiff.c
86 +index 5b5f9f53..45864b76 100644
87 +--- a/src/aiff.c
88 ++++ b/src/aiff.c
89 +@@ -1759,7 +1759,7 @@ aiff_read_chanmap (SF_PRIVATE * psf, unsigned dword)
90 + psf_binheader_readf (psf, "j", dword - bytesread) ;
91 +
92 + if (map_info->channel_map != NULL)
93 +- { size_t chanmap_size = psf->sf.channels * sizeof (psf->channel_map [0]) ;
94 ++ { size_t chanmap_size = SF_MIN (psf->sf.channels, layout_tag & 0xffff) * sizeof (psf->channel_map [0]) ;
95 +
96 + free (psf->channel_map) ;
97 +
98
99 diff --git a/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2017-8362.patch b/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2017-8362.patch
100 new file mode 100644
101 index 00000000000..54fbfb44c3b
102 --- /dev/null
103 +++ b/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2017-8362.patch
104 @@ -0,0 +1,50 @@
105 +From ef1dbb2df1c0e741486646de40bd638a9c4cd808 Mon Sep 17 00:00:00 2001
106 +From: Erik de Castro Lopo <erikd@×××××××××.com>
107 +Date: Fri, 14 Apr 2017 15:19:16 +1000
108 +Subject: [PATCH] src/flac.c: Fix a buffer read overflow
109 +
110 +A file (generated by a fuzzer) which increased the number of channels
111 +from one frame to the next could cause a read beyond the end of the
112 +buffer provided by libFLAC. Only option is to abort the read.
113 +
114 +Closes: https://github.com/erikd/libsndfile/issues/231
115 +---
116 + src/flac.c | 11 +++++++++--
117 + 1 file changed, 9 insertions(+), 2 deletions(-)
118 +
119 +diff --git a/src/flac.c b/src/flac.c
120 +index 5a4f8c21..e4f9aaa0 100644
121 +--- a/src/flac.c
122 ++++ b/src/flac.c
123 +@@ -169,6 +169,14 @@ flac_buffer_copy (SF_PRIVATE *psf)
124 + const int32_t* const *buffer = pflac->wbuffer ;
125 + unsigned i = 0, j, offset, channels, len ;
126 +
127 ++ if (psf->sf.channels != (int) frame->header.channels)
128 ++ { psf_log_printf (psf, "Error: FLAC frame changed from %d to %d channels\n"
129 ++ "Nothing to do but to error out.\n" ,
130 ++ psf->sf.channels, frame->header.channels) ;
131 ++ psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
132 ++ return 0 ;
133 ++ } ;
134 ++
135 + /*
136 + ** frame->header.blocksize is variable and we're using a constant blocksize
137 + ** of FLAC__MAX_BLOCK_SIZE.
138 +@@ -202,7 +210,6 @@ flac_buffer_copy (SF_PRIVATE *psf)
139 + return 0 ;
140 + } ;
141 +
142 +-
143 + len = SF_MIN (pflac->len, frame->header.blocksize) ;
144 +
145 + if (pflac->remain % channels != 0)
146 +@@ -436,7 +443,7 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_
147 + { case FLAC__METADATA_TYPE_STREAMINFO :
148 + if (psf->sf.channels > 0 && psf->sf.channels != (int) metadata->data.stream_info.channels)
149 + { psf_log_printf (psf, "Error: FLAC stream changed from %d to %d channels\n"
150 +- "Nothing to be but to error out.\n" ,
151 ++ "Nothing to do but to error out.\n" ,
152 + psf->sf.channels, metadata->data.stream_info.channels) ;
153 + psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
154 + return ;
155
156 diff --git a/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2017-8363.patch b/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2017-8363.patch
157 new file mode 100644
158 index 00000000000..d0aa400bdd9
159 --- /dev/null
160 +++ b/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2017-8363.patch
161 @@ -0,0 +1,28 @@
162 +From cd7da8dbf6ee4310d21d9e44b385d6797160d9e8 Mon Sep 17 00:00:00 2001
163 +From: Erik de Castro Lopo <erikd@×××××××××.com>
164 +Date: Wed, 12 Apr 2017 20:19:34 +1000
165 +Subject: [PATCH] src/flac.c: Fix another memory leak
166 +
167 +When the FLAC decoder was passed a malformed file, the associated
168 +`FLAC__StreamDecoder` object was not getting released.
169 +
170 +Closes: https://github.com/erikd/libsndfile/issues/233
171 +---
172 + src/flac.c | 4 +++-
173 + 1 file changed, 3 insertions(+), 1 deletion(-)
174 +
175 +diff --git a/src/flac.c b/src/flac.c
176 +index 986a7b8f..5a4f8c21 100644
177 +--- a/src/flac.c
178 ++++ b/src/flac.c
179 +@@ -841,7 +841,9 @@ flac_read_header (SF_PRIVATE *psf)
180 +
181 + psf_log_printf (psf, "End\n") ;
182 +
183 +- if (psf->error == 0)
184 ++ if (psf->error != 0)
185 ++ FLAC__stream_decoder_delete (pflac->fsd) ;
186 ++ else
187 + { FLAC__uint64 position ;
188 +
189 + FLAC__stream_decoder_get_decode_position (pflac->fsd, &position) ;
190
191 diff --git a/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2017-8365.patch b/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2017-8365.patch
192 new file mode 100644
193 index 00000000000..1dc5b57f1d3
194 --- /dev/null
195 +++ b/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2017-8365.patch
196 @@ -0,0 +1,64 @@
197 +From fd0484aba8e51d16af1e3a880f9b8b857b385eb3 Mon Sep 17 00:00:00 2001
198 +From: Erik de Castro Lopo <erikd@×××××××××.com>
199 +Date: Wed, 12 Apr 2017 19:45:30 +1000
200 +Subject: [PATCH] FLAC: Fix a buffer read overrun
201 +
202 +Buffer read overrun occurs when reading a FLAC file that switches
203 +from 2 channels to one channel mid-stream. Only option is to
204 +abort the read.
205 +
206 +Closes: https://github.com/erikd/libsndfile/issues/230
207 +---
208 + src/common.h | 1 +
209 + src/flac.c | 13 +++++++++++++
210 + src/sndfile.c | 1 +
211 + 3 files changed, 15 insertions(+)
212 +
213 +diff --git a/src/common.h b/src/common.h
214 +index 0bd810c3..e2669b6a 100644
215 +--- a/src/common.h
216 ++++ b/src/common.h
217 +@@ -725,6 +725,7 @@ enum
218 + SFE_FLAC_INIT_DECODER,
219 + SFE_FLAC_LOST_SYNC,
220 + SFE_FLAC_BAD_SAMPLE_RATE,
221 ++ SFE_FLAC_CHANNEL_COUNT_CHANGED,
222 + SFE_FLAC_UNKOWN_ERROR,
223 +
224 + SFE_WVE_NOT_WVE,
225 +diff --git a/src/flac.c b/src/flac.c
226 +index 84de0e26..986a7b8f 100644
227 +--- a/src/flac.c
228 ++++ b/src/flac.c
229 +@@ -434,6 +434,19 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_
230 +
231 + switch (metadata->type)
232 + { case FLAC__METADATA_TYPE_STREAMINFO :
233 ++ if (psf->sf.channels > 0 && psf->sf.channels != (int) metadata->data.stream_info.channels)
234 ++ { psf_log_printf (psf, "Error: FLAC stream changed from %d to %d channels\n"
235 ++ "Nothing to be but to error out.\n" ,
236 ++ psf->sf.channels, metadata->data.stream_info.channels) ;
237 ++ psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
238 ++ return ;
239 ++ } ;
240 ++
241 ++ if (psf->sf.channels > 0 && psf->sf.samplerate != (int) metadata->data.stream_info.sample_rate)
242 ++ { psf_log_printf (psf, "Warning: FLAC stream changed sample rates from %d to %d.\n"
243 ++ "Carrying on as if nothing happened.",
244 ++ psf->sf.samplerate, metadata->data.stream_info.sample_rate) ;
245 ++ } ;
246 + psf->sf.channels = metadata->data.stream_info.channels ;
247 + psf->sf.samplerate = metadata->data.stream_info.sample_rate ;
248 + psf->sf.frames = metadata->data.stream_info.total_samples ;
249 +diff --git a/src/sndfile.c b/src/sndfile.c
250 +index 41875610..e2a87be8 100644
251 +--- a/src/sndfile.c
252 ++++ b/src/sndfile.c
253 +@@ -245,6 +245,7 @@ ErrorStruct SndfileErrors [] =
254 + { SFE_FLAC_INIT_DECODER , "Error : problem with initialization of the flac decoder." },
255 + { SFE_FLAC_LOST_SYNC , "Error : flac decoder lost sync." },
256 + { SFE_FLAC_BAD_SAMPLE_RATE, "Error : flac does not support this sample rate." },
257 ++ { SFE_FLAC_CHANNEL_COUNT_CHANGED, "Error : flac channel changed mid stream." },
258 + { SFE_FLAC_UNKOWN_ERROR , "Error : unknown error in flac decoder." },
259 +
260 + { SFE_WVE_NOT_WVE , "Error : not a WVE file." },
261
262 diff --git a/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2018-13139.patch b/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2018-13139.patch
263 index 18e6ae76e62..f75843267b0 100644
264 --- a/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2018-13139.patch
265 +++ b/media-libs/libsndfile/files/libsndfile-1.0.28-CVE-2018-13139.patch
266 @@ -28,4 +28,4 @@ index 53660310..225b4d54 100644
267 +
268 state.channels = sfinfo.channels ;
269 sfinfo.channels = 1 ;
270 -
271 \ No newline at end of file
272 +
273
274 diff --git a/media-libs/libsndfile/libsndfile-1.0.28-r4.ebuild b/media-libs/libsndfile/libsndfile-1.0.28-r4.ebuild
275 new file mode 100644
276 index 00000000000..0473759374d
277 --- /dev/null
278 +++ b/media-libs/libsndfile/libsndfile-1.0.28-r4.ebuild
279 @@ -0,0 +1,70 @@
280 +# Copyright 1999-2018 Gentoo Authors
281 +# Distributed under the terms of the GNU General Public License v2
282 +
283 +EAPI=7
284 +
285 +PYTHON_COMPAT=( python{2_7,3_4,3_5,3_6} pypy{,3} )
286 +
287 +inherit python-any-r1 multilib-minimal
288 +
289 +MY_P=${P/_pre/pre}
290 +
291 +DESCRIPTION="C library for reading and writing files containing sampled sound"
292 +HOMEPAGE="http://www.mega-nerd.com/libsndfile"
293 +if [[ ${MY_P} == ${P} ]]; then
294 + SRC_URI="http://www.mega-nerd.com/libsndfile/files/${P}.tar.gz"
295 +else
296 + SRC_URI="http://www.mega-nerd.com/tmp/${MY_P}b.tar.gz"
297 +fi
298 +
299 +LICENSE="LGPL-2.1"
300 +SLOT="0"
301 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~x64-solaris ~x86-solaris"
302 +IUSE="alsa minimal sqlite static-libs test"
303 +
304 +RDEPEND="
305 + !minimal? (
306 + >=media-libs/flac-1.2.1-r5[${MULTILIB_USEDEP}]
307 + >=media-libs/libogg-1.3.0[${MULTILIB_USEDEP}]
308 + >=media-libs/libvorbis-1.3.3-r1[${MULTILIB_USEDEP}]
309 + )
310 + alsa? ( media-libs/alsa-lib )
311 + sqlite? ( >=dev-db/sqlite-3.2 )"
312 +DEPEND="${RDEPEND}"
313 +BDEPEND="
314 + virtual/pkgconfig
315 + test? ( ${PYTHON_DEPS} )"
316 +
317 +S=${WORKDIR}/${MY_P}
318 +
319 +PATCHES=(
320 + "${FILESDIR}"/${P}-arm-varargs-failure.patch
321 + "${FILESDIR}"/${P}-CVE-2017-12562.patch
322 + "${FILESDIR}"/${P}-CVE-2018-13139.patch
323 + "${FILESDIR}"/${P}-CVE-2017-6892.patch
324 + "${FILESDIR}"/${P}-CVE-2017-836{3,5,2}.patch
325 + "${FILESDIR}"/${P}-CVE-2017-14634.patch
326 +)
327 +
328 +pkg_setup() {
329 + use test && python-any-r1_pkg_setup
330 +}
331 +
332 +multilib_src_configure() {
333 + ECONF_SOURCE="${S}" econf \
334 + --disable-octave \
335 + --enable-gcc-pipe \
336 + --enable-gcc-opt \
337 + $(use_enable static-libs static) \
338 + $(use_enable !minimal external-libs) \
339 + $(multilib_native_enable full-suite) \
340 + $(multilib_native_use_enable alsa) \
341 + $(multilib_native_use_enable sqlite)
342 +}
343 +
344 +multilib_src_install_all() {
345 + einstalldocs
346 +
347 + # package provides .pc files
348 + find "${D}" -name '*.la' -delete || die
349 +}