View | Details | Raw Unified | Return to bug 248268
Collapse All | Expand All

(-)b/audio/libsndfile/Makefile (-25 / +28 lines)
Lines 2-11 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	libsndfile
4
PORTNAME=	libsndfile
5
PORTVERSION=	1.0.28
5
DISTVERSION=	1.0.29pre2.20200620
6
PORTREVISION=	2
7
CATEGORIES=	audio
6
CATEGORIES=	audio
8
MASTER_SITES=	http://www.mega-nerd.com/libsndfile/files/
9
7
10
MAINTAINER=	multimedia@FreeBSD.org
8
MAINTAINER=	multimedia@FreeBSD.org
11
COMMENT=	Reading and writing files containing sampled sound (like WAV or AIFF)
9
COMMENT=	Reading and writing files containing sampled sound (like WAV or AIFF)
Lines 13-49 COMMENT= Reading and writing files containing sampled sound (like WAV or AIFF) Link Here
13
LICENSE=	LGPL21+
11
LICENSE=	LGPL21+
14
LICENSE_FILE=	${WRKSRC}/COPYING
12
LICENSE_FILE=	${WRKSRC}/COPYING
15
13
16
USES=		cpe gmake libtool localbase pkgconfig
14
USES=		cmake cpe localbase pkgconfig python:build,test shebangfix
15
SHEBANG_FILES=	programs/test-sndfile-metadata-set.py \
16
		src/binheader_writef_check.py \
17
		src/create_symbols_file.py
18
17
CPE_VENDOR=	${CPE_PRODUCT}_project
19
CPE_VENDOR=	${CPE_PRODUCT}_project
18
GNU_CONFIGURE=	yes
20
19
CONFIGURE_ARGS=	--disable-gcc-pipe \
21
USE_GITHUB=	yes
20
		--disable-sqlite \
22
GH_ACCOUNT=	erikd
21
		--disable-alsa \
23
GH_TAGNAME=	2ccb23f
22
		--disable-octave \
24
23
		--with-pkgconfigdir=${PREFIX}/libdata/pkgconfig
24
USE_LDCONFIG=	yes
25
USE_LDCONFIG=	yes
25
TEST_TARGET=	check
26
INSTALL_TARGET=	install-strip
27
26
28
OPTIONS_DEFINE=	CPU_CLIP EXTERNAL DOCS
27
OPTIONS_DEFINE=	DOCS EXTERNAL STATIC TEST
28
OPTIONS_SUB=	yes
29
OPTIONS_DEFAULT=	EXTERNAL
29
OPTIONS_DEFAULT=	EXTERNAL
30
CPU_CLIP_DESC=	Allow machine-dependent clipping
30
EXTERNAL_DESC=	Enable FLAC, Ogg Vorbis, Opus support
31
EXTERNAL_DESC=	Enable FLAC and Ogg Vorbis support
31
TEST_IMPLIES=	STATIC
32
33
CPU_CLIP_VARS=	MANUAL_PACKAGE_BUILD="WITH_CPU_CLIP may customize the package for the build machine"
34
CPU_CLIP_CONFIGURE_OFF=	--disable-cpu-clip
35
32
36
EXTERNAL_LIB_DEPENDS=	libFLAC.so:audio/flac \
33
EXTERNAL_LIB_DEPENDS=	libFLAC.so:audio/flac \
37
			libogg.so:audio/libogg \
34
			libogg.so:audio/libogg \
35
			libopus.so:audio/opus \
38
			libvorbis.so:audio/libvorbis
36
			libvorbis.so:audio/libvorbis
39
EXTERNAL_CONFIGURE_OFF=	--disable-external-libs
40
37
41
post-patch:
38
STATIC_CMAKE_OFF=	-DBUILD_SHARED_LIBS:BOOL=ON
42
	@${REINPLACE_CMD} -e '/^SUBDIRS =/s/ doc / /g' ${WRKSRC}/Makefile.in
39
40
TEST_CMAKE_ON=	-DBUILD_TESTING:BOOL=ON
41
TEST_CMAKE_OFF=	-DBUILD_TESTING:BOOL=OFF
42
43
.include <bsd.port.options.mk>
44
45
.if ! ${PORT_OPTIONS:MEXTERNAL}
46
EXTRA_PATCHES=	${FILESDIR}/extrapatch-cmake_SndFileChecks.cmake-disableexternallibs
47
.endif
43
48
44
post-install-DOCS-on:
49
do-test:
45
	@${MKDIR} ${STAGEDIR}${DOCSDIR}
50
	(cd ${TEST_WRKSRC} && CTEST_OUTPUT_ON_FAILURE=1 ctest -V)
46
	@${TAR} -C ${WRKSRC}/doc --exclude "*Makefile*" --exclude "*.in" \
47
		-cf - . | ${TAR} -C ${STAGEDIR}${DOCSDIR} --unlink -xf -
48
51
49
.include <bsd.port.mk>
52
.include <bsd.port.mk>
(-)b/audio/libsndfile/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1494006962
1
TIMESTAMP = 1595508551
2
SHA256 (libsndfile-1.0.28.tar.gz) = 1ff33929f042fa333aed1e8923aa628c3ee9e1eb85512686c55092d1e5a9dfa9
2
SHA256 (erikd-libsndfile-1.0.29pre2.20200620-2ccb23f_GH0.tar.gz) = 70fee769ab60c579090edf5a43a4959a71feb14f0e531394f4e1c1a9741258c3
3
SIZE (libsndfile-1.0.28.tar.gz) = 1202833
3
SIZE (erikd-libsndfile-1.0.29pre2.20200620-2ccb23f_GH0.tar.gz) = 721895
(-)b/audio/libsndfile/files/extrapatch-cmake_SndFileChecks.cmake-disableexternallibs (+32 lines)
Added Link Here
1
--- cmake/SndFileChecks.cmake.orig	2020-07-23 13:42:53 UTC
2
+++ cmake/SndFileChecks.cmake
3
@@ -31,28 +31,7 @@ if (VCPKG_TOOLCHAIN AND (NOT CMAKE_VERSION VERSION_LES
4
 	set (CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
5
 endif ()
6
 
7
-if (CMAKE_FIND_PACKAGE_PREFER_CONFIG)
8
-	find_package (Ogg 1.3 CONFIG)
9
-	find_package (Vorbis CONFIG COMPONENTS Enc)
10
-	find_package (FLAC CONFIG)
11
-	find_package (Opus CONFIG)
12
-
13
-	include (FindPackageHandleStandardArgs)
14
-	find_package_handle_standard_args (Ogg CONFIG_MODE)
15
-	find_package_handle_standard_args (Vorbis CONFIG_MODE)
16
-	find_package_handle_standard_args (FLAC CONFIG_MODE)
17
-	find_package_handle_standard_args (Opus CONFIG_MODE)
18
-else ()
19
-	find_package (Ogg 1.3)
20
-	find_package (Vorbis COMPONENTS Enc)
21
-	find_package (FLAC)
22
-	find_package (Opus)
23
-endif ()
24
-if (Vorbis_FOUND AND FLAC_FOUND AND Opus_FOUND)
25
-	set (HAVE_EXTERNAL_XIPH_LIBS 1)
26
-else ()
27
-	set (HAVE_EXTERNAL_XIPH_LIBS 0)
28
-endif ()
29
+set (HAVE_EXTERNAL_XIPH_LIBS 0)
30
 
31
 find_package (Speex)
32
 find_package (SQLite3)
(-)b/audio/libsndfile/files/patch-CMakeLists.txt (+13 lines)
Added Link Here
1
--- CMakeLists.txt.orig	2020-07-23 12:41:43 UTC
2
+++ CMakeLists.txt
3
@@ -74,8 +74,8 @@ cmake_dependent_option (ENABLE_COMPATIBLE_LIBSNDFILE_N
4
 
5
 set (HAVE_EXTERNAL_XIPH_LIBS ${ENABLE_EXTERNAL_LIBS})
6
 set (HAVE_SQLITE3 ${BUILD_REGTEST})
7
-set (HAVE_ALSA_ASOUNDLIB_H ${ALSA_FOUND})
8
-set (HAVE_SNDIO_H ${SNDIO_FOUND})
9
+set (HAVE_ALSA_ASOUNDLIB_H 0)
10
+set (HAVE_SNDIO_H 0)
11
 
12
 set (ENABLE_EXPERIMENTAL_CODE ${ENABLE_EXPERIMENTAL})
13
 set (HAVE_SPEEX ${ENABLE_EXPERIMENTAL})
(-)a/audio/libsndfile/files/patch-CVE-2017-12562 (-82 lines)
Removed Link Here
1
From cf7a8182c2642c50f1cf90dddea9ce96a8bad2e8 Mon Sep 17 00:00:00 2001
2
From: =?UTF-8?q?J=C3=B6rn=20Heusipp?= <osmanx@problemloesungsmaschine.de>
3
Date: Wed, 14 Jun 2017 12:25:40 +0200
4
Subject: [PATCH] src/common.c: Fix heap buffer overflows when writing strings
5
 in binheader
6
7
Fixes the following problems:
8
 1. Case 's' only enlarges the buffer by 16 bytes instead of size bytes.
9
 2. psf_binheader_writef() enlarges the header buffer (if needed) prior to the
10
    big switch statement by an amount (16 bytes) which is enough for all cases
11
    where only a single value gets added. Cases 's', 'S', 'p' however
12
    additionally write an arbitrary length block of data and again enlarge the
13
    buffer to the required amount. However, the required space calculation does
14
    not take into account the size of the length field which gets output before
15
    the data.
16
 3. Buffer size requirement calculation in case 'S' does not account for the
17
    padding byte ("size += (size & 1) ;" happens after the calculation which
18
    uses "size").
19
 4. Case 'S' can overrun the header buffer by 1 byte when no padding is
20
    involved
21
    ("memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + 1) ;" while
22
    the buffer is only guaranteed to have "size" space available).
23
 5. "psf->header.ptr [psf->header.indx] = 0 ;" in case 'S' always writes 1 byte
24
    beyond the space which is guaranteed to be allocated in the header buffer.
25
 6. Case 's' can overrun the provided source string by 1 byte if padding is
26
    involved ("memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;"
27
    where "size" is "strlen (strptr) + 1" (which includes the 0 terminator,
28
    plus optionally another 1 which is padding and not guaranteed to be
29
    readable via the source string pointer).
30
31
Closes: https://github.com/erikd/libsndfile/issues/292
32
--- src/common.c.orig	2017-04-02 06:33:16 UTC
33
+++ src/common.c
34
@@ -681,16 +681,16 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
35
 					/* Write a C string (guaranteed to have a zero terminator). */
36
 					strptr = va_arg (argptr, char *) ;
37
 					size = strlen (strptr) + 1 ;
38
-					size += (size & 1) ;
39
 
40
-					if (psf->header.indx + (sf_count_t) size >= psf->header.len && psf_bump_header_allocation (psf, 16))
41
+					if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
42
 						return count ;
43
 
44
 					if (psf->rwf_endian == SF_ENDIAN_BIG)
45
-						header_put_be_int (psf, size) ;
46
+						header_put_be_int (psf, size + (size & 1)) ;
47
 					else
48
-						header_put_le_int (psf, size) ;
49
+						header_put_le_int (psf, size + (size & 1)) ;
50
 					memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;
51
+					size += (size & 1) ;
52
 					psf->header.indx += size ;
53
 					psf->header.ptr [psf->header.indx - 1] = 0 ;
54
 					count += 4 + size ;
55
@@ -703,16 +703,15 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
56
 					*/
57
 					strptr = va_arg (argptr, char *) ;
58
 					size = strlen (strptr) ;
59
-					if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
60
+					if (psf->header.indx + 4 + (sf_count_t) size + (sf_count_t) (size & 1) > psf->header.len && psf_bump_header_allocation (psf, 4 + size + (size & 1)))
61
 						return count ;
62
 					if (psf->rwf_endian == SF_ENDIAN_BIG)
63
 						header_put_be_int (psf, size) ;
64
 					else
65
 						header_put_le_int (psf, size) ;
66
-					memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + 1) ;
67
+					memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + (size & 1)) ;
68
 					size += (size & 1) ;
69
 					psf->header.indx += size ;
70
-					psf->header.ptr [psf->header.indx] = 0 ;
71
 					count += 4 + size ;
72
 					break ;
73
 
74
@@ -724,7 +723,7 @@ psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
75
 					size = (size & 1) ? size : size + 1 ;
76
 					size = (size > 254) ? 254 : size ;
77
 
78
-					if (psf->header.indx + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, size))
79
+					if (psf->header.indx + 1 + (sf_count_t) size > psf->header.len && psf_bump_header_allocation (psf, 1 + size))
80
 						return count ;
81
 
82
 					header_put_byte (psf, size) ;
(-)a/audio/libsndfile/files/patch-CVE-2017-14634 (-29 lines)
Removed Link Here
1
From 85c877d5072866aadbe8ed0c3e0590fbb5e16788 Mon Sep 17 00:00:00 2001
2
From: Fabian Greffrath <fabian@greffrath.com>
3
Date: Thu, 28 Sep 2017 12:15:04 +0200
4
Subject: [PATCH] double64_init: Check psf->sf.channels against upper bound
5
6
This prevents division by zero later in the code.
7
8
While the trivial case to catch this (i.e. sf.channels < 1) has already
9
been covered, a crafted file may report a number of channels that is
10
so high (i.e. > INT_MAX/sizeof(double)) that it "somehow" gets
11
miscalculated to zero (if this makes sense) in the determination of the
12
blockwidth. Since we only support a limited number of channels anyway,
13
make sure to check here as well.
14
15
CVE-2017-14634
16
17
Closes: https://github.com/erikd/libsndfile/issues/318
18
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
19
--- src/double64.c.orig	2016-04-01 21:08:53 UTC
20
+++ src/double64.c
21
@@ -91,7 +91,7 @@ int
22
 double64_init	(SF_PRIVATE *psf)
23
 {	static int double64_caps ;
24
 
25
-	if (psf->sf.channels < 1)
26
+	if (psf->sf.channels < 1 || psf->sf.channels > SF_MAX_CHANNELS)
27
 	{	psf_log_printf (psf, "double64_init : internal error : channels = %d\n", psf->sf.channels) ;
28
 		return SFE_INTERNAL ;
29
 		} ;
(-)a/audio/libsndfile/files/patch-CVE-2017-17456_2017-17457_2018-19661_2018-19662 (-90 lines)
Removed Link Here
1
From: Hugo Lefeuvre <hle@owl.eu.com>
2
Date: Mon, 24 Dec 2018 06:43:48 +0100
3
Subject: a/ulaw: fix multiple buffer overflows (#432)
4
5
i2ulaw_array() and i2alaw_array() fail to handle ptr [count] = INT_MIN
6
properly, leading to buffer underflow. INT_MIN is a special value
7
since - INT_MIN cannot be represented as int.
8
9
In this case round - INT_MIN to INT_MAX and proceed as usual.
10
11
f2ulaw_array() and f2alaw_array() fail to handle ptr [count] = NaN
12
properly, leading to null pointer dereference.
13
14
In this case, arbitrarily set the buffer value to 0.
15
16
This commit fixes #429 (CVE-2018-19661 and CVE-2018-19662) and
17
fixes #344 (CVE-2017-17456 and CVE-2017-17457).
18
---
19
 src/alaw.c | 9 +++++++--
20
 src/ulaw.c | 9 +++++++--
21
 2 files changed, 14 insertions(+), 4 deletions(-)
22
23
diff --git a/src/alaw.c b/src/alaw.c
24
index 063fd1a..4220224 100644
25
--- src/alaw.c
26
+++ src/alaw.c
27
@@ -19,6 +19,7 @@
28
 #include	"sfconfig.h"
29
 
30
 #include	<math.h>
31
+#include	<limits.h>
32
 
33
 #include	"sndfile.h"
34
 #include	"common.h"
35
@@ -326,7 +327,9 @@ s2alaw_array (const short *ptr, int count, unsigned char *buffer)
36
 static inline void
37
 i2alaw_array (const int *ptr, int count, unsigned char *buffer)
38
 {	while (--count >= 0)
39
-	{	if (ptr [count] >= 0)
40
+	{	if (ptr [count] == INT_MIN)
41
+			buffer [count] = alaw_encode [INT_MAX >> (16 + 4)] ;
42
+		else if (ptr [count] >= 0)
43
 			buffer [count] = alaw_encode [ptr [count] >> (16 + 4)] ;
44
 		else
45
 			buffer [count] = 0x7F & alaw_encode [- ptr [count] >> (16 + 4)] ;
46
@@ -346,7 +349,9 @@ f2alaw_array (const float *ptr, int count, unsigned char *buffer, float normfact
47
 static inline void
48
 d2alaw_array (const double *ptr, int count, unsigned char *buffer, double normfact)
49
 {	while (--count >= 0)
50
-	{	if (ptr [count] >= 0)
51
+	{	if (!isfinite (ptr [count]))
52
+			buffer [count] = 0 ;
53
+		else if (ptr [count] >= 0)
54
 			buffer [count] = alaw_encode [lrint (normfact * ptr [count])] ;
55
 		else
56
 			buffer [count] = 0x7F & alaw_encode [- lrint (normfact * ptr [count])] ;
57
diff --git a/src/ulaw.c b/src/ulaw.c
58
index e50b4cb..b6070ad 100644
59
--- src/ulaw.c
60
+++ src/ulaw.c
61
@@ -19,6 +19,7 @@
62
 #include	"sfconfig.h"
63
 
64
 #include	<math.h>
65
+#include	<limits.h>
66
 
67
 #include	"sndfile.h"
68
 #include	"common.h"
69
@@ -827,7 +828,9 @@ s2ulaw_array (const short *ptr, int count, unsigned char *buffer)
70
 static inline void
71
 i2ulaw_array (const int *ptr, int count, unsigned char *buffer)
72
 {	while (--count >= 0)
73
-	{	if (ptr [count] >= 0)
74
+	{	if (ptr [count] == INT_MIN)
75
+			buffer [count] = ulaw_encode [INT_MAX >> (16 + 2)] ;
76
+		else if (ptr [count] >= 0)
77
 			buffer [count] = ulaw_encode [ptr [count] >> (16 + 2)] ;
78
 		else
79
 			buffer [count] = 0x7F & ulaw_encode [-ptr [count] >> (16 + 2)] ;
80
@@ -847,7 +850,9 @@ f2ulaw_array (const float *ptr, int count, unsigned char *buffer, float normfact
81
 static inline void
82
 d2ulaw_array (const double *ptr, int count, unsigned char *buffer, double normfact)
83
 {	while (--count >= 0)
84
-	{	if (ptr [count] >= 0)
85
+	{	if (!isfinite (ptr [count]))
86
+			buffer [count] = 0 ;
87
+		else if (ptr [count] >= 0)
88
 			buffer [count] = ulaw_encode [lrint (normfact * ptr [count])] ;
89
 		else
90
 			buffer [count] = 0x7F & ulaw_encode [- lrint (normfact * ptr [count])] ;
(-)a/audio/libsndfile/files/patch-CVE-2017-6892 (-19 lines)
Removed Link Here
1
From f833c53cb596e9e1792949f762e0b33661822748 Mon Sep 17 00:00:00 2001
2
From: Erik de Castro Lopo <erikd@mega-nerd.com>
3
Date: Tue, 23 May 2017 20:15:24 +1000
4
Subject: [PATCH] src/aiff.c: Fix a buffer read overflow
5
6
Secunia Advisory SA76717.
7
8
Found by: Laurent Delosieres, Secunia Research at Flexera Software
9
--- src/aiff.c.orig	2017-04-01 07:18:02 UTC
10
+++ src/aiff.c
11
@@ -1905,7 +1905,7 @@ aiff_read_chanmap (SF_PRIVATE * psf, unsigned dword)
12
 		psf_binheader_readf (psf, "j", dword - bytesread) ;
13
 
14
 	if (map_info->channel_map != NULL)
15
-	{	size_t chanmap_size = psf->sf.channels * sizeof (psf->channel_map [0]) ;
16
+	{	size_t chanmap_size = SF_MIN (psf->sf.channels, layout_tag & 0xffff) * sizeof (psf->channel_map [0]) ;
17
 
18
 		free (psf->channel_map) ;
19
 
(-)a/audio/libsndfile/files/patch-CVE-2017-8361 (-53 lines)
Removed Link Here
1
From fd0484aba8e51d16af1e3a880f9b8b857b385eb3 Mon Sep 17 00:00:00 2001
2
From: Erik de Castro Lopo <erikd@mega-nerd.com>
3
Date: Wed, 12 Apr 2017 19:45:30 +1000
4
Subject: [PATCH] FLAC: Fix a buffer read overrun
5
6
Buffer read overrun occurs when reading a FLAC file that switches
7
from 2 channels to one channel mid-stream. Only option is to
8
abort the read.
9
10
Closes: https://github.com/erikd/libsndfile/issues/230
11
Addresses: CVE-2017-8361 CVE-2017-8363 CVE-2017-8365
12
--- src/common.h.orig	2017-04-01 09:40:45 UTC
13
+++ src/common.h
14
@@ -725,6 +725,7 @@ enum
15
 	SFE_FLAC_INIT_DECODER,
16
 	SFE_FLAC_LOST_SYNC,
17
 	SFE_FLAC_BAD_SAMPLE_RATE,
18
+	SFE_FLAC_CHANNEL_COUNT_CHANGED,
19
 	SFE_FLAC_UNKOWN_ERROR,
20
 
21
 	SFE_WVE_NOT_WVE,
22
--- src/flac.c.orig	2018-03-01 19:51:26 UTC
23
+++ src/flac.c
24
@@ -434,6 +434,19 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_
25
 
26
 	switch (metadata->type)
27
 	{	case FLAC__METADATA_TYPE_STREAMINFO :
28
+			if (psf->sf.channels > 0 && psf->sf.channels != (int) metadata->data.stream_info.channels)
29
+			{	psf_log_printf (psf, "Error: FLAC stream changed from %d to %d channels\n"
30
+									"Nothing to be but to error out.\n" ,
31
+									psf->sf.channels, metadata->data.stream_info.channels) ;
32
+				psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
33
+				return ;
34
+				} ;
35
+
36
+			if (psf->sf.channels > 0 && psf->sf.samplerate != (int) metadata->data.stream_info.sample_rate)
37
+			{	psf_log_printf (psf, "Warning: FLAC stream changed sample rates from %d to %d.\n"
38
+									"Carrying on as if nothing happened.",
39
+									psf->sf.samplerate, metadata->data.stream_info.sample_rate) ;
40
+				} ;
41
 			psf->sf.channels = metadata->data.stream_info.channels ;
42
 			psf->sf.samplerate = metadata->data.stream_info.sample_rate ;
43
 			psf->sf.frames = metadata->data.stream_info.total_samples ;
44
--- src/sndfile.c.orig	2017-04-02 06:33:16 UTC
45
+++ src/sndfile.c
46
@@ -245,6 +245,7 @@ ErrorStruct SndfileErrors [] =
47
 	{	SFE_FLAC_INIT_DECODER	, "Error : problem with initialization of the flac decoder." },
48
 	{	SFE_FLAC_LOST_SYNC		, "Error : flac decoder lost sync." },
49
 	{	SFE_FLAC_BAD_SAMPLE_RATE, "Error : flac does not support this sample rate." },
50
+	{	SFE_FLAC_CHANNEL_COUNT_CHANGED, "Error : flac channel changed mid stream." },
51
 	{	SFE_FLAC_UNKOWN_ERROR	, "Error : unknown error in flac decoder." },
52
 
53
 	{	SFE_WVE_NOT_WVE			, "Error : not a WVE file." },
(-)a/audio/libsndfile/files/patch-CVE-2017-8362 (-44 lines)
Removed Link Here
1
From ef1dbb2df1c0e741486646de40bd638a9c4cd808 Mon Sep 17 00:00:00 2001
2
From: Erik de Castro Lopo <erikd@mega-nerd.com>
3
Date: Fri, 14 Apr 2017 15:19:16 +1000
4
Subject: [PATCH] src/flac.c: Fix a buffer read overflow
5
6
A file (generated by a fuzzer) which increased the number of channels
7
from one frame to the next could cause a read beyond the end of the
8
buffer provided by libFLAC. Only option is to abort the read.
9
10
Closes: https://github.com/erikd/libsndfile/issues/231
11
--- src/flac.c.orig 2017-04-01 09:40:45 UTC
12
+++ src/flac.c
13
@@ -169,6 +169,14 @@ flac_buffer_copy (SF_PRIVATE *psf)
14
 	const int32_t* const *buffer = pflac->wbuffer ;
15
 	unsigned i = 0, j, offset, channels, len ;
16
 
17
+	if (psf->sf.channels != (int) frame->header.channels)
18
+	{	psf_log_printf (psf, "Error: FLAC frame changed from %d to %d channels\n"
19
+									"Nothing to do but to error out.\n" ,
20
+									psf->sf.channels, frame->header.channels) ;
21
+		psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
22
+		return 0 ;
23
+		} ;
24
+
25
 	/*
26
 	**	frame->header.blocksize is variable and we're using a constant blocksize
27
 	**	of FLAC__MAX_BLOCK_SIZE.
28
@@ -202,7 +210,6 @@ flac_buffer_copy (SF_PRIVATE *psf)
29
 		return 0 ;
30
 		} ;
31
 
32
-
33
 	len = SF_MIN (pflac->len, frame->header.blocksize) ;
34
 
35
 	if (pflac->remain % channels != 0)
36
@@ -436,7 +443,7 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_
37
 	{	case FLAC__METADATA_TYPE_STREAMINFO :
38
 			if (psf->sf.channels > 0 && psf->sf.channels != (int) metadata->data.stream_info.channels)
39
 			{	psf_log_printf (psf, "Error: FLAC stream changed from %d to %d channels\n"
40
-									"Nothing to be but to error out.\n" ,
41
+									"Nothing to do but to error out.\n" ,
42
 									psf->sf.channels, metadata->data.stream_info.channels) ;
43
 				psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
44
 				return ;
(-)a/audio/libsndfile/files/patch-CVE-2017-8363 (-22 lines)
Removed Link Here
1
From cd7da8dbf6ee4310d21d9e44b385d6797160d9e8 Mon Sep 17 00:00:00 2001
2
From: Erik de Castro Lopo <erikd@mega-nerd.com>
3
Date: Wed, 12 Apr 2017 20:19:34 +1000
4
Subject: [PATCH] src/flac.c: Fix another memory leak
5
6
When the FLAC decoder was passed a malformed file, the associated
7
`FLAC__StreamDecoder` object was not getting released.
8
9
Closes: https://github.com/erikd/libsndfile/issues/233
10
--- src/flac.c.orig 2018-03-01 09:40:45 UTC
11
+++ src/flac.c
12
@@ -841,7 +841,9 @@ flac_read_header (SF_PRIVATE *psf)
13
 
14
 	psf_log_printf (psf, "End\n") ;
15
 
16
-	if (psf->error == 0)
17
+	if (psf->error != 0)
18
+		FLAC__stream_decoder_delete (pflac->fsd) ;
19
+	else
20
 	{	FLAC__uint64 position ;
21
 
22
 		FLAC__stream_decoder_get_decode_position (pflac->fsd, &position) ;
(-)a/audio/libsndfile/files/patch-CVE-2018-19758 (-31 lines)
Removed Link Here
1
From: Erik de Castro Lopo <erikd@mega-nerd.com>
2
Date: Tue, 1 Jan 2019 20:11:46 +1100
3
Subject: src/wav.c: Fix heap read overflow
4
5
This is CVE-2018-19758.
6
7
Closes: https://github.com/erikd/libsndfile/issues/435
8
---
9
 src/wav.c | 4 +++-
10
 1 file changed, 3 insertions(+), 1 deletion(-)
11
12
diff --git a/src/wav.c b/src/wav.c
13
index 4b943dc..59015a1 100644
14
--- src/wav.c
15
+++ src/wav.c
16
@@ -1,5 +1,5 @@
17
 /*
18
-** Copyright (C) 1999-2016 Erik de Castro Lopo <erikd@mega-nerd.com>
19
+** Copyright (C) 1999-2019 Erik de Castro Lopo <erikd@mega-nerd.com>
20
 ** Copyright (C) 2004-2005 David Viens <davidv@plogue.com>
21
 **
22
 ** This program is free software; you can redistribute it and/or modify
23
@@ -1094,6 +1094,8 @@ wav_write_header (SF_PRIVATE *psf, int calc_length)
24
 		psf_binheader_writef (psf, "44", 0, 0) ; /* SMTPE format */
25
 		psf_binheader_writef (psf, "44", psf->instrument->loop_count, 0) ;
26
 
27
+		/* Loop count is signed 16 bit number so we limit it range to something sensible. */
28
+		psf->instrument->loop_count &= 0x7fff ;
29
 		for (tmp = 0 ; tmp < psf->instrument->loop_count ; tmp++)
30
 		{	int type ;
31
 
(-)a/audio/libsndfile/files/patch-Check-MAX_CHANNELS-in-sndfile-deinterleave (-30 lines)
Removed Link Here
1
From: "Brett T. Warden" <brett.t.warden@intel.com>
2
Date: Tue, 28 Aug 2018 12:01:17 -0700
3
Subject: Check MAX_CHANNELS in sndfile-deinterleave
4
5
Allocated buffer has space for only 16 channels. Verify that input file
6
meets this limit.
7
8
Fixes #397
9
---
10
 programs/sndfile-deinterleave.c | 7 +++++++
11
 1 file changed, 7 insertions(+)
12
13
diff --git a/programs/sndfile-deinterleave.c b/programs/sndfile-deinterleave.c
14
index e27593e..cb497e1 100644
15
--- programs/sndfile-deinterleave.c
16
+++ programs/sndfile-deinterleave.c
17
@@ -89,6 +89,13 @@ main (int argc, char **argv)
18
 		exit (1) ;
19
 		} ;
20
 
21
+	if (sfinfo.channels > MAX_CHANNELS)
22
+	{	printf ("\nError : Input file '%s' has too many (%d) channels. Limit is %d.\n",
23
+			argv [1], sfinfo.channels, MAX_CHANNELS) ;
24
+		exit (1) ;
25
+		} ;
26
+
27
+
28
 	state.channels = sfinfo.channels ;
29
 	sfinfo.channels = 1 ;
30
 
(-)b/audio/libsndfile/files/patch-cmake_SndFileChecks.cmake (+14 lines)
Added Link Here
1
--- cmake/SndFileChecks.cmake.orig	2020-06-20 08:18:11 UTC
2
+++ cmake/SndFileChecks.cmake
3
@@ -22,11 +22,6 @@ else ()
4
 endif ()
5
 set (SF_COUNT_MAX 0x7fffffffffffffffll)
6
 
7
-if (NOT WIN32)
8
-	find_package (ALSA)
9
-	find_package (Sndio)
10
-endif ()
11
-
12
 if (VCPKG_TOOLCHAIN AND (NOT CMAKE_VERSION VERSION_LESS 3.15))
13
 	set (CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
14
 endif ()
(-)a/audio/libsndfile/files/patch-rf64_arm (-49 lines)
Removed Link Here
1
From: Erik de Castro Lopez <erikd@mega-nerd.com>
2
Date: Tue, 20 Jun 2017 00:00:00 +0200
3
Subject: fix RF64 on armel/armhf archs
4
5
Origin: upstream
6
Applied-Upstream: 9d470ee5577d3ccedb1c28c7e0a7295ba17feaf5
7
Last-Update: 2017-06-20
8
---
9
 src/rf64.c | 11 +++++++++--
10
 1 file changed, 9 insertions(+), 2 deletions(-)
11
12
diff --git a/src/rf64.c b/src/rf64.c
13
index c373bb0..60a3309 100644
14
--- src/rf64.c
15
+++ src/rf64.c
16
@@ -339,6 +339,12 @@ rf64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
17
 					} ;
18
 				break ;
19
 
20
+			case JUNK_MARKER :
21
+			case PAD_MARKER :
22
+				psf_log_printf (psf, "%M : %d\n", marker, chunk_size) ;
23
+				psf_binheader_readf (psf, "j", chunk_size) ;
24
+				break ;
25
+
26
 			default :
27
 					if (chunk_size >= 0xffff0000)
28
 					{	psf_log_printf (psf, "*** Unknown chunk marker (%X) at position %D with length %u. Exiting parser.\n", marker, psf_ftell (psf) - 8, chunk_size) ;
29
@@ -659,7 +665,7 @@ rf64_write_header (SF_PRIVATE *psf, int calc_length)
30
 
31
 	if (wpriv->rf64_downgrade && psf->filelength < RIFF_DOWNGRADE_BYTES)
32
 	{	psf_binheader_writef (psf, "etm8m", RIFF_MARKER, (psf->filelength < 8) ? 8 : psf->filelength - 8, WAVE_MARKER) ;
33
-		psf_binheader_writef (psf, "m4884", JUNK_MARKER, 20, 0, 0, 0, 0) ;
34
+		psf_binheader_writef (psf, "m4z", JUNK_MARKER, 24, 24) ;
35
 		add_fact_chunk = 1 ;
36
 		}
37
 	else
38
@@ -735,9 +741,10 @@ rf64_write_header (SF_PRIVATE *psf, int calc_length)
39
 
40
 #endif
41
 
42
+	/* Padding may be needed if string data sizes change. */
43
 	pad_size = psf->dataoffset - 16 - psf->header.indx ;
44
 	if (pad_size >= 0)
45
-		psf_binheader_writef (psf, "m4z", PAD_MARKER, pad_size, make_size_t (pad_size)) ;
46
+		psf_binheader_writef (psf, "m4z", PAD_MARKER, (unsigned int) pad_size, make_size_t (pad_size)) ;
47
 
48
 	if (wpriv->rf64_downgrade && (psf->filelength < RIFF_DOWNGRADE_BYTES))
49
 		psf_binheader_writef (psf, "tm8", data_MARKER, psf->datalength) ;
(-)a/audio/libsndfile/files/patch-typos (-67 lines)
Removed Link Here
1
From: IOhannes m zmoelnig <umlaeute@debian.org>
2
Date: Wed, 5 Oct 2016 00:00:00 +0200
3
Subject: fixed spelling errors
4
5
Forwarded: yes
6
Last-Update: 2016-10-05
7
8
discovered by lintian
9
---
10
 doc/bugs.html              | 2 +-
11
 programs/sndfile-convert.c | 2 +-
12
 src/ogg.c                  | 2 +-
13
 src/wavlike.c              | 2 +-
14
 4 files changed, 4 insertions(+), 4 deletions(-)
15
16
diff --git a/doc/bugs.html b/doc/bugs.html
17
index 3a441fe..addedb8 100644
18
--- doc/bugs.html
19
+++ doc/bugs.html
20
@@ -31,7 +31,7 @@
21
 	<UL>
22
 	<LI>	Compilation problems on new platforms.
23
 	<LI>	Errors being detected during the `make check' process.
24
-	<LI>	Segmentation faults occuring inside libsndfile.
25
+	<LI>	Segmentation faults occurring inside libsndfile.
26
 	<LI>	libsndfile hanging when opening a file.
27
 	<LI>	Supported sound file types being incorrectly read or written.
28
 	<LI>	Omissions, errors or spelling mistakes in the documentation.
29
diff --git a/programs/sndfile-convert.c b/programs/sndfile-convert.c
30
index dff7f79..896838f 100644
31
--- programs/sndfile-convert.c
32
+++ programs/sndfile-convert.c
33
@@ -317,7 +317,7 @@ main (int argc, char * argv [])
34
 	if ((sfinfo.format & SF_FORMAT_SUBMASK) == SF_FORMAT_GSM610 && sfinfo.samplerate != 8000)
35
 	{	printf (
36
 			"WARNING: GSM 6.10 data format only supports 8kHz sample rate. The converted\n"
37
-			"ouput file will contain the input data converted to the GSM 6.10 data format\n"
38
+			"output file will contain the input data converted to the GSM 6.10 data format\n"
39
 			"but not re-sampled.\n"
40
 			) ;
41
 		} ;
42
diff --git a/src/ogg.c b/src/ogg.c
43
index 0856f77..e01ebe1 100644
44
--- src/ogg.c
45
+++ src/ogg.c
46
@@ -193,7 +193,7 @@ ogg_stream_classify (SF_PRIVATE *psf, OGG_PRIVATE* odata)
47
 			break ;
48
 		} ;
49
 
50
-	psf_log_printf (psf, "This Ogg bitstream contains some uknown data type.\n") ;
51
+	psf_log_printf (psf, "This Ogg bitstream contains some unknown data type.\n") ;
52
 	return SFE_UNIMPLEMENTED ;
53
 } /* ogg_stream_classify */
54
 
55
diff --git a/src/wavlike.c b/src/wavlike.c
56
index 86ebf01..c053da3 100644
57
--- src/wavlike.c
58
+++ src/wavlike.c
59
@@ -161,7 +161,7 @@ wavlike_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize)
60
 	{	psf_log_printf (psf, "  Bit Width     : 24\n") ;
61
 
62
 		psf_log_printf (psf, "\n"
63
-			"  Ambiguous information in 'fmt ' chunk. Possibile file types:\n"
64
+			"  Ambiguous information in 'fmt ' chunk. Possible file types:\n"
65
 			"    0) Invalid IEEE float file generated by Syntrillium's Cooledit!\n"
66
 			"    1) File generated by ALSA's arecord containing 24 bit samples in 32 bit containers.\n"
67
 			"    2) 24 bit file with incorrect Block Align value.\n"
(-)b/audio/libsndfile/pkg-plist (-11 / +9 lines)
Lines 10-35 bin/sndfile-play Link Here
10
bin/sndfile-salvage
10
bin/sndfile-salvage
11
include/sndfile.h
11
include/sndfile.h
12
include/sndfile.hh
12
include/sndfile.hh
13
lib/libsndfile.a
13
lib/cmake/SndFile/SndFileConfig.cmake
14
lib/libsndfile.so
14
lib/cmake/SndFile/SndFileConfigVersion.cmake
15
lib/libsndfile.so.1
15
lib/cmake/SndFile/SndFileTargets-%%CMAKE_BUILD_TYPE%%.cmake
16
lib/libsndfile.so.1.0.28
16
lib/cmake/SndFile/SndFileTargets.cmake
17
%%STATIC%%lib/libsndfile.a
18
%%NO_STATIC%%lib/libsndfile.so
19
%%NO_STATIC%%lib/libsndfile.so.1
20
%%NO_STATIC%%lib/libsndfile.so.1.0.29
17
libdata/pkgconfig/sndfile.pc
21
libdata/pkgconfig/sndfile.pc
18
man/man1/sndfile-cmp.1.gz
22
man/man1/sndfile-cmp.1.gz
19
man/man1/sndfile-concat.1.gz
23
man/man1/sndfile-concat.1.gz
20
man/man1/sndfile-convert.1.gz
24
man/man1/sndfile-convert.1.gz
21
man/man1/sndfile-deinterleave.1.gz
22
man/man1/sndfile-info.1.gz
25
man/man1/sndfile-info.1.gz
23
man/man1/sndfile-interleave.1.gz
26
man/man1/sndfile-interleave.1.gz
24
man/man1/sndfile-metadata-get.1.gz
27
man/man1/sndfile-metadata-get.1.gz
25
man/man1/sndfile-metadata-set.1.gz
26
man/man1/sndfile-play.1.gz
28
man/man1/sndfile-play.1.gz
27
man/man1/sndfile-salvage.1.gz
29
man/man1/sndfile-salvage.1.gz
28
%%PORTDOCS%%%%DOCSDIR%%/AUTHORS
29
%%PORTDOCS%%%%DOCSDIR%%/ChangeLog
30
%%PORTDOCS%%%%DOCSDIR%%/FAQ.html
30
%%PORTDOCS%%%%DOCSDIR%%/FAQ.html
31
%%PORTDOCS%%%%DOCSDIR%%/NEWS
32
%%PORTDOCS%%%%DOCSDIR%%/README
33
%%PORTDOCS%%%%DOCSDIR%%/api.html
31
%%PORTDOCS%%%%DOCSDIR%%/api.html
34
%%PORTDOCS%%%%DOCSDIR%%/bugs.html
32
%%PORTDOCS%%%%DOCSDIR%%/bugs.html
35
%%PORTDOCS%%%%DOCSDIR%%/command.html
33
%%PORTDOCS%%%%DOCSDIR%%/command.html
Lines 40-45 man/man1/sndfile-salvage.1.gz Link Here
40
%%PORTDOCS%%%%DOCSDIR%%/lists.html
38
%%PORTDOCS%%%%DOCSDIR%%/lists.html
41
%%PORTDOCS%%%%DOCSDIR%%/new_file_type.HOWTO
39
%%PORTDOCS%%%%DOCSDIR%%/new_file_type.HOWTO
42
%%PORTDOCS%%%%DOCSDIR%%/octave.html
40
%%PORTDOCS%%%%DOCSDIR%%/octave.html
41
%%PORTDOCS%%%%DOCSDIR%%/print.css
43
%%PORTDOCS%%%%DOCSDIR%%/sndfile_info.html
42
%%PORTDOCS%%%%DOCSDIR%%/sndfile_info.html
44
%%PORTDOCS%%%%DOCSDIR%%/tutorial.html
43
%%PORTDOCS%%%%DOCSDIR%%/tutorial.html
45
%%PORTDOCS%%%%DOCSDIR%%/win32.html
44
%%PORTDOCS%%%%DOCSDIR%%/win32.html
46
- 

Return to bug 248268