summaryrefslogtreecommitdiff
path: root/legacy/sox
diff options
context:
space:
mode:
authorZach van Rijn <me@zv.io>2023-02-06 03:51:29 +0000
committerZach van Rijn <me@zv.io>2023-02-06 03:53:58 +0000
commit491802e5efd6fa2d5543de51e93ffc2ae0a6f1b1 (patch)
tree1b72677c935f5c82312062ad291474fba200c2be /legacy/sox
parent130b4b415b5591a7320ea3cfdf87c43987916655 (diff)
downloadpackages-491802e5efd6fa2d5543de51e93ffc2ae0a6f1b1.tar.gz
packages-491802e5efd6fa2d5543de51e93ffc2ae0a6f1b1.tar.bz2
packages-491802e5efd6fa2d5543de51e93ffc2ae0a6f1b1.tar.xz
packages-491802e5efd6fa2d5543de51e93ffc2ae0a6f1b1.zip
user/sox: move to legacy/
This package has numerous CVEs and does not currently build on our pmmx target. It is not required by any other packages at the moment. See also: #961.
Diffstat (limited to 'legacy/sox')
-rw-r--r--legacy/sox/APKBUILD87
-rw-r--r--legacy/sox/CVE-2017-11332.patch28
-rw-r--r--legacy/sox/CVE-2017-11358.patch44
-rw-r--r--legacy/sox/CVE-2017-11359.patch30
-rw-r--r--legacy/sox/CVE-2017-15370.patch28
-rw-r--r--legacy/sox/CVE-2017-15371.patch40
-rw-r--r--legacy/sox/CVE-2017-15372.patch100
-rw-r--r--legacy/sox/CVE-2017-15642.patch34
-rw-r--r--legacy/sox/CVE-2017-18189.patch33
-rw-r--r--legacy/sox/CVE-2019-13590.patch33
-rw-r--r--legacy/sox/CVE-2019-8354.patch28
-rw-r--r--legacy/sox/CVE-2019-8355.patch59
-rw-r--r--legacy/sox/CVE-2019-8356.patch92
-rw-r--r--legacy/sox/CVE-2019-8357.patch28
-rw-r--r--legacy/sox/disable-pipe-file-detection.patch11
15 files changed, 675 insertions, 0 deletions
diff --git a/legacy/sox/APKBUILD b/legacy/sox/APKBUILD
new file mode 100644
index 000000000..8e9fe9934
--- /dev/null
+++ b/legacy/sox/APKBUILD
@@ -0,0 +1,87 @@
+# Contributor: Łukasz Jendrysik <scadu@yandex.com>
+# Maintainer:
+pkgname=sox
+pkgver=14.4.2
+pkgrel=2
+pkgdesc="Convert between various audio formats"
+url="http://sox.sourceforge.net/"
+arch="all"
+options="!check" # No test suite.
+license="GPL-2.0+ AND LGPL-2.1+ AND MIT AND BSD-1-Clause"
+makedepends="alsa-lib-dev ffmpeg-dev file-dev flac-dev gsm-dev lame-dev
+ libao-dev libid3tag-dev libmad-dev libogg-dev libsamplerate-dev
+ libsndfile-dev libvorbis-dev opusfile-dev pulseaudio-dev
+ autoconf automake libtool"
+depends=""
+subpackages="$pkgname-dev $pkgname-doc"
+source="https://downloads.sourceforge.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.gz
+ CVE-2017-11332.patch
+ CVE-2017-11358.patch
+ CVE-2017-11359.patch
+ CVE-2017-15370.patch
+ CVE-2017-15371.patch
+ CVE-2017-15372.patch
+ CVE-2017-15642.patch
+ CVE-2017-18189.patch
+ CVE-2019-13590.patch
+ CVE-2019-8354.patch
+ CVE-2019-8355.patch
+ CVE-2019-8356.patch
+ CVE-2019-8357.patch
+ disable-pipe-file-detection.patch
+ "
+
+# secfixes:
+# 14.4.2-r2:
+# - CVE-2017-11332
+# - CVE-2017-11358
+# - CVE-2017-11359
+# - CVE-2017-15370
+# - CVE-2017-15371
+# - CVE-2017-15372
+# - CVE-2017-15642
+# - CVE-2017-18189
+# - CVE-2019-13590
+# - CVE-2019-8354
+# - CVE-2019-8355
+# - CVE-2019-8356
+# - CVE-2019-8357
+
+prepare() {
+ default_prepare
+ autoreconf -vif
+}
+
+build() {
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --with-dyn-default \
+ --with-distro="${DISTRO_NAME:-Adélie Linux}"
+ make
+}
+
+package() {
+ make DESTDIR="$pkgdir" install
+ ln -sf play "$pkgdir"/usr/bin/rec
+ ln -sf ../man1/sox.1.gz "$pkgdir"/usr/share/man/man7/soxeffect.7
+ rm "$pkgdir"/usr/lib/sox/*.a
+}
+
+sha512sums="b5c6203f4f5577503a034fe5b3d6a033ee97fe4d171c533933e2b036118a43a14f97c9668433229708609ccf9ee16abdeca3fc7501aa0aafe06baacbba537eca sox-14.4.2.tar.gz
+b4bded0b15a2243fbb404a33fccf45ad5634d6c6e0f60b49b967592f00ff9bc3657ebcfa42b18a5af804e7f04a700773bece5951739b8206b2c68c46c9ec4c7f CVE-2017-11332.patch
+28ffd5eef149563a1cdfcd920a89a0e2247ddbf4ed10a76c4e34ee57e3a30ec3a98bacf53fe1675da1431dd40c30b13cae0b9a1e26153c1aad6144322b7d78b0 CVE-2017-11358.patch
+2c95d85f94877bf1637d2c1297944a77a8854506cad35b1c0d632237133cd970da82cded817696b19acde25b0e570f4c86659cc362a910e4ea76a037e3e56214 CVE-2017-11359.patch
+bcbfd0785751372cd959a7419d88af24bb041dd02d3d0cf2f0dab46b6f6b55f284c1d823d20e5a0eae15191f3ccb2eefa2026287fdfbecb064722b006970ee00 CVE-2017-15370.patch
+b116887f52eb4b70de9dda5f14e581579c4c1755c39100d88c4b8645bf9e053cfe87de3346eb138edc45fd2c36f0e1755f91e09511d279fe6d4661099c578420 CVE-2017-15371.patch
+f8a4d38cfad80a50b9c758b222d83f6b51d96f1491862680e1632eec2a5c2a7c6f968660307f0f403e0b7537f7da19a510945648bdef8f1302fd4683be869581 CVE-2017-15372.patch
+259980ea6fe08a2481a478a4a21b11a7fc4390b1b53023009d85fb2185ee63c42d2762e024af20912e7277688fac98e4eaa66b4a4e79840517ff2481ad50327e CVE-2017-15642.patch
+de510114a9fbbbabe62149f3c22ebd1fae65ed68e6ed0b818f367bbee806c9e04be6db0c8e64f4985b7bd95dd0cc643e1475767fda4e405931f25104b4a2e39f CVE-2017-18189.patch
+eab27e22035bdbe00d0dc4117f98bf9c5dcad4513a27e0e8a83506b94fca8055bc6ce532d24306aa8434942bef111b3511daf260df56fafb7b4ac5ed2075e3f7 CVE-2019-13590.patch
+61342fad71dbe7f0ff10a7327eeed901c0defd5aafaace4ac755032ccf687d875856490c30f2af050823fd6ff1a1c7f503ae26670225eab916ab59fa857a8cb3 CVE-2019-8354.patch
+3f05ab71680a67c9e8a4b33c70cb19a623f0925a2620ab007dc8d4a82caf5b73b50e3e5d40e242d6f65420d444b91e11bee09e4398e8079ca4af60bd34097593 CVE-2019-8355.patch
+6eca5096c658a61939902a70d218b5662b663df84173d09d5b23f497bdcb81c04cd94d8debed2818079c342cec80ec29ff33d572611826bdbc12a5d465a20241 CVE-2019-8356.patch
+82fbbf62a7124248ce74cf0daab0cd224a3da80e62923db58b8be31c4f145abe0e653f6968d0f6b862e5554d080d0f85b0bc0bcdb6dea34c130aa4ee9106d915 CVE-2019-8357.patch
+eb90574a7c174a32ac77aa09a2bb4ebbea407463517e55943e16efd8b7c52393c6b7a6b2778d696f708627271f4d2212221a85fc50d2500b32143139a37a957a disable-pipe-file-detection.patch"
diff --git a/legacy/sox/CVE-2017-11332.patch b/legacy/sox/CVE-2017-11332.patch
new file mode 100644
index 000000000..511049d8e
--- /dev/null
+++ b/legacy/sox/CVE-2017-11332.patch
@@ -0,0 +1,28 @@
+From 6e177c455fb554327ff8125b6e6dde1568610abe Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans@mansr.com>
+Date: Sun, 5 Nov 2017 16:29:28 +0000
+Subject: [PATCH] wav: fix crash if channel count is zero (CVE-2017-11332)
+
+---
+ src/wav.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/src/wav.c b/src/wav.c
+index 5202556c..71fd52ac 100644
+--- a/src/wav.c
++++ b/src/wav.c
+@@ -712,6 +712,11 @@ static int startread(sox_format_t * ft)
+ else
+ lsx_report("User options overriding channels read in .wav header");
+
++ if (ft->signal.channels == 0) {
++ lsx_fail_errno(ft, SOX_EHDR, "Channel count is zero");
++ return SOX_EOF;
++ }
++
+ if (ft->signal.rate == 0 || ft->signal.rate == dwSamplesPerSecond)
+ ft->signal.rate = dwSamplesPerSecond;
+ else
+--
+2.25.0
+
diff --git a/legacy/sox/CVE-2017-11358.patch b/legacy/sox/CVE-2017-11358.patch
new file mode 100644
index 000000000..4fadeda30
--- /dev/null
+++ b/legacy/sox/CVE-2017-11358.patch
@@ -0,0 +1,44 @@
+From e410d00c4821726accfbe1f825f2def6376e181f Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans@mansr.com>
+Date: Sun, 5 Nov 2017 16:43:35 +0000
+Subject: [PATCH] hcom: fix crash on input with corrupt dictionary
+ (CVE-2017-11358)
+
+---
+ src/hcom.c | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/src/hcom.c b/src/hcom.c
+index e76820e9..be17d9d2 100644
+--- a/src/hcom.c
++++ b/src/hcom.c
+@@ -73,6 +73,14 @@ typedef struct {
+ size_t pos; /* Where next byte goes */
+ } priv_t;
+
++static int dictvalid(int n, int size, int left, int right)
++{
++ if (n > 0 && left < 0)
++ return 1;
++
++ return (unsigned)left < size && (unsigned)right < size;
++}
++
+ static int startread(sox_format_t * ft)
+ {
+ priv_t *p = (priv_t *) ft->priv;
+@@ -150,6 +158,11 @@ static int startread(sox_format_t * ft)
+ lsx_debug("%d %d",
+ p->dictionary[i].dict_leftson,
+ p->dictionary[i].dict_rightson);
++ if (!dictvalid(i, dictsize, p->dictionary[i].dict_leftson,
++ p->dictionary[i].dict_rightson)) {
++ lsx_fail_errno(ft, SOX_EHDR, "Invalid dictionary");
++ return SOX_EOF;
++ }
+ }
+ rc = lsx_skipbytes(ft, (size_t) 1); /* skip pad byte */
+ if (rc)
+--
+2.25.0
+
diff --git a/legacy/sox/CVE-2017-11359.patch b/legacy/sox/CVE-2017-11359.patch
new file mode 100644
index 000000000..cb96c4a71
--- /dev/null
+++ b/legacy/sox/CVE-2017-11359.patch
@@ -0,0 +1,30 @@
+From 7b3f30e13e4845bafc93215a372c6eb7dcf04118 Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans@mansr.com>
+Date: Sun, 5 Nov 2017 17:02:11 +0000
+Subject: [PATCH] wav: fix crash writing header when channel count >64k
+ (CVE-2017-11359)
+
+---
+ src/wav.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/src/wav.c b/src/wav.c
+index 71fd52ac..eca1cde5 100644
+--- a/src/wav.c
++++ b/src/wav.c
+@@ -1379,6 +1379,12 @@ static int wavwritehdr(sox_format_t * ft, int second_header)
+ long blocksWritten = 0;
+ sox_bool isExtensible = sox_false; /* WAVE_FORMAT_EXTENSIBLE? */
+
++ if (ft->signal.channels > UINT16_MAX) {
++ lsx_fail_errno(ft, SOX_EOF, "Too many channels (%u)",
++ ft->signal.channels);
++ return SOX_EOF;
++ }
++
+ dwSamplesPerSecond = ft->signal.rate;
+ wChannels = ft->signal.channels;
+ wBitsPerSample = ft->encoding.bits_per_sample;
+--
+2.25.0
+
diff --git a/legacy/sox/CVE-2017-15370.patch b/legacy/sox/CVE-2017-15370.patch
new file mode 100644
index 000000000..9e6a7f7ee
--- /dev/null
+++ b/legacy/sox/CVE-2017-15370.patch
@@ -0,0 +1,28 @@
+From e076a7ad504add6e8c3b8699e8587eef0e0d9bc3 Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans@mansr.com>
+Date: Sun, 5 Nov 2017 16:21:23 +0000
+Subject: [PATCH] wav: ima_adpcm: fix buffer overflow on corrupt input
+ (CVE-2017-15370)
+
+Add the same check bad block size as was done for MS adpcm in commit
+f39c574b ("More checks for invalid MS ADPCM blocks").
+---
+ src/wav.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/wav.c b/src/wav.c
+index eca1cde5..fad334cf 100644
+--- a/src/wav.c
++++ b/src/wav.c
+@@ -127,7 +127,7 @@ static unsigned short ImaAdpcmReadBlock(sox_format_t * ft)
+ /* work with partial blocks. Specs say it should be null */
+ /* padded but I guess this is better than trailing quiet. */
+ samplesThisBlock = lsx_ima_samples_in((size_t)0, (size_t)ft->signal.channels, bytesRead, (size_t) 0);
+- if (samplesThisBlock == 0)
++ if (samplesThisBlock == 0 || samplesThisBlock > wav->samplesPerBlock)
+ {
+ lsx_warn("Premature EOF on .wav input file");
+ return 0;
+--
+2.25.0
+
diff --git a/legacy/sox/CVE-2017-15371.patch b/legacy/sox/CVE-2017-15371.patch
new file mode 100644
index 000000000..7b38943f2
--- /dev/null
+++ b/legacy/sox/CVE-2017-15371.patch
@@ -0,0 +1,40 @@
+From 968c689ad2c4269a1a853434d99aa7ebf0c01354 Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans@mansr.com>
+Date: Sun, 5 Nov 2017 15:57:48 +0000
+Subject: [PATCH] flac: fix crash on corrupt metadata (CVE-2017-15371)
+
+---
+ src/flac.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/src/flac.c b/src/flac.c
+index 0d7829ec..07f45c1b 100644
+--- a/src/flac.c
++++ b/src/flac.c
+@@ -119,9 +119,10 @@ static void decoder_metadata_callback(FLAC__StreamDecoder const * const flac, FL
+ p->total_samples = metadata->data.stream_info.total_samples;
+ }
+ else if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
++ const FLAC__StreamMetadata_VorbisComment *vc = &metadata->data.vorbis_comment;
+ size_t i;
+
+- if (metadata->data.vorbis_comment.num_comments == 0)
++ if (vc->num_comments == 0)
+ return;
+
+ if (ft->oob.comments != NULL) {
+@@ -129,8 +130,9 @@ static void decoder_metadata_callback(FLAC__StreamDecoder const * const flac, FL
+ return;
+ }
+
+- for (i = 0; i < metadata->data.vorbis_comment.num_comments; ++i)
+- sox_append_comment(&ft->oob.comments, (char const *) metadata->data.vorbis_comment.comments[i].entry);
++ for (i = 0; i < vc->num_comments; ++i)
++ if (vc->comments[i].entry)
++ sox_append_comment(&ft->oob.comments, (char const *) vc->comments[i].entry);
+ }
+ }
+
+--
+2.25.0
+
diff --git a/legacy/sox/CVE-2017-15372.patch b/legacy/sox/CVE-2017-15372.patch
new file mode 100644
index 000000000..dd7fcff5d
--- /dev/null
+++ b/legacy/sox/CVE-2017-15372.patch
@@ -0,0 +1,100 @@
+From 515b986139183326cc40c67c75f83edc60826a9e Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans@mansr.com>
+Date: Wed, 8 Nov 2017 00:27:46 +0000
+Subject: [PATCH] adpcm: fix stack overflow with >4 channels (CVE-2017-15372)
+
+---
+ src/adpcm.c | 8 +++++++-
+ src/adpcm.h | 3 +++
+ src/wav.c | 5 ++++-
+ 3 files changed, 14 insertions(+), 2 deletions(-)
+
+diff --git a/src/adpcm.c b/src/adpcm.c
+index 2e13867e..f64b7d5c 100644
+--- a/src/adpcm.c
++++ b/src/adpcm.c
+@@ -71,6 +71,11 @@ const short lsx_ms_adpcm_i_coef[7][2] = {
+ { 392,-232}
+ };
+
++extern void *lsx_ms_adpcm_alloc(unsigned chans)
++{
++ return lsx_malloc(chans * sizeof(MsState_t));
++}
++
+ static inline sox_sample_t AdpcmDecode(sox_sample_t c, MsState_t *state,
+ sox_sample_t sample1, sox_sample_t sample2)
+ {
+@@ -102,6 +107,7 @@ static inline sox_sample_t AdpcmDecode(sox_sample_t c, MsState_t *state,
+
+ /* lsx_ms_adpcm_block_expand_i() outputs interleaved samples into one output buffer */
+ const char *lsx_ms_adpcm_block_expand_i(
++ void *priv,
+ unsigned chans, /* total channels */
+ int nCoef,
+ const short *coef,
+@@ -113,7 +119,7 @@ const char *lsx_ms_adpcm_block_expand_i(
+ const unsigned char *ip;
+ unsigned ch;
+ const char *errmsg = NULL;
+- MsState_t state[4]; /* One decompressor state for each channel */
++ MsState_t *state = priv; /* One decompressor state for each channel */
+
+ /* Read the four-byte header for each channel */
+ ip = ibuff;
+diff --git a/src/adpcm.h b/src/adpcm.h
+index af4d6f08..db5cc615 100644
+--- a/src/adpcm.h
++++ b/src/adpcm.h
+@@ -29,8 +29,11 @@
+ /* default coef sets */
+ extern const short lsx_ms_adpcm_i_coef[7][2];
+
++extern void *lsx_ms_adpcm_alloc(unsigned chans);
++
+ /* lsx_ms_adpcm_block_expand_i() outputs interleaved samples into one output buffer */
+ extern const char *lsx_ms_adpcm_block_expand_i(
++ void *priv,
+ unsigned chans, /* total channels */
+ int nCoef,
+ const short *coef,
+diff --git a/src/wav.c b/src/wav.c
+index fad334cf..066be6d7 100644
+--- a/src/wav.c
++++ b/src/wav.c
+@@ -82,6 +82,7 @@ typedef struct {
+ /* following used by *ADPCM wav files */
+ unsigned short nCoefs; /* ADPCM: number of coef sets */
+ short *lsx_ms_adpcm_i_coefs; /* ADPCM: coef sets */
++ void *ms_adpcm_data; /* Private data of adpcm decoder */
+ unsigned char *packet; /* Temporary buffer for packets */
+ short *samples; /* interleaved samples buffer */
+ short *samplePtr; /* Pointer to current sample */
+@@ -175,7 +176,7 @@ static unsigned short AdpcmReadBlock(sox_format_t * ft)
+ }
+ }
+
+- errmsg = lsx_ms_adpcm_block_expand_i(ft->signal.channels, wav->nCoefs, wav->lsx_ms_adpcm_i_coefs, wav->packet, wav->samples, samplesThisBlock);
++ errmsg = lsx_ms_adpcm_block_expand_i(wav->ms_adpcm_data, ft->signal.channels, wav->nCoefs, wav->lsx_ms_adpcm_i_coefs, wav->packet, wav->samples, samplesThisBlock);
+
+ if (errmsg)
+ lsx_warn("%s", errmsg);
+@@ -791,6 +792,7 @@ static int startread(sox_format_t * ft)
+
+ /* nCoefs, lsx_ms_adpcm_i_coefs used by adpcm.c */
+ wav->lsx_ms_adpcm_i_coefs = lsx_malloc(wav->nCoefs * 2 * sizeof(short));
++ wav->ms_adpcm_data = lsx_ms_adpcm_alloc(wChannels);
+ {
+ int i, errct=0;
+ for (i=0; len>=2 && i < 2*wav->nCoefs; i++) {
+@@ -1216,6 +1218,7 @@ static int stopread(sox_format_t * ft)
+ free(wav->packet);
+ free(wav->samples);
+ free(wav->lsx_ms_adpcm_i_coefs);
++ free(wav->ms_adpcm_data);
+ free(wav->comment);
+ wav->comment = NULL;
+
+--
+2.25.0
+
diff --git a/legacy/sox/CVE-2017-15642.patch b/legacy/sox/CVE-2017-15642.patch
new file mode 100644
index 000000000..95beb4f6f
--- /dev/null
+++ b/legacy/sox/CVE-2017-15642.patch
@@ -0,0 +1,34 @@
+From f56c0dbca8f5bd02ea88970c248c0d087386e807 Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans@mansr.com>
+Date: Mon, 20 Nov 2017 11:03:15 +0000
+Subject: [PATCH] aiff: fix crash on empty comment chunk (CVE-2017-15642)
+
+This fixes a use after free and double free if an empty comment
+chunk follows a non-empty one.
+---
+ src/aiff.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/aiff.c b/src/aiff.c
+index 240d2e1f..11ddb542 100644
+--- a/src/aiff.c
++++ b/src/aiff.c
+@@ -62,7 +62,6 @@ int lsx_aiffstartread(sox_format_t * ft)
+ size_t ssndsize = 0;
+ char *annotation;
+ char *author;
+- char *comment = NULL;
+ char *copyright;
+ char *nametext;
+
+@@ -270,6 +269,7 @@ int lsx_aiffstartread(sox_format_t * ft)
+ free(annotation);
+ }
+ else if (strncmp(buf, "COMT", (size_t)4) == 0) {
++ char *comment = NULL;
+ rc = commentChunk(&comment, "Comment:", ft);
+ if (rc) {
+ /* Fail already called in function */
+--
+2.25.0
+
diff --git a/legacy/sox/CVE-2017-18189.patch b/legacy/sox/CVE-2017-18189.patch
new file mode 100644
index 000000000..aa3791d01
--- /dev/null
+++ b/legacy/sox/CVE-2017-18189.patch
@@ -0,0 +1,33 @@
+From 09d7388c8ad5701ed9c59d1d600ff6154b066397 Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans@mansr.com>
+Date: Thu, 9 Nov 2017 11:45:10 +0000
+Subject: [PATCH] xa: validate channel count (CVE-2017-18189)
+
+A corrupt header specifying zero channels would send read_channels()
+into an infinite loop. Prevent this by sanity checking the channel
+count in open_read(). Also add an upper bound to prevent overflow
+in multiplication.
+---
+ src/xa.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/src/xa.c b/src/xa.c
+index 81a76772..9fc086ec 100644
+--- a/src/xa.c
++++ b/src/xa.c
+@@ -143,6 +143,12 @@ static int startread(sox_format_t * ft)
+ lsx_report("User options overriding rate read in .xa header");
+ }
+
++ if (ft->signal.channels == 0 || ft->signal.channels > UINT16_MAX) {
++ lsx_fail_errno(ft, SOX_EFMT, "invalid channel count %d",
++ ft->signal.channels);
++ return SOX_EOF;
++ }
++
+ /* Check for supported formats */
+ if (ft->encoding.bits_per_sample != 16) {
+ lsx_fail_errno(ft, SOX_EFMT, "%d-bit sample resolution not supported.",
+--
+2.25.0
+
diff --git a/legacy/sox/CVE-2019-13590.patch b/legacy/sox/CVE-2019-13590.patch
new file mode 100644
index 000000000..a09b11bae
--- /dev/null
+++ b/legacy/sox/CVE-2019-13590.patch
@@ -0,0 +1,33 @@
+From 7b6a889217d62ed7e28188621403cc7542fd1f7e Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans@mansr.com>
+Date: Tue, 4 Feb 2020 12:55:18 +0000
+Subject: [PATCH] sox-fmt: validate comments_bytes before use (CVE-2019-13590)
+ [bug #325]
+
+Cap the comments size to 1 GB to avoid overflows in subsequent
+arithmetic.
+
+The missing null check mentioned in the bug report is bogus since
+lsx_calloc() returns a valid pointer or aborts.
+---
+ src/sox-fmt.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/sox-fmt.c b/src/sox-fmt.c
+index aad965cd..11c88771 100644
+--- a/src/sox-fmt.c
++++ b/src/sox-fmt.c
+@@ -46,7 +46,9 @@ static int startread(sox_format_t * ft)
+ lsx_readdw(ft, &comments_bytes))
+ return SOX_EOF;
+
+- if (((headers_bytes + 4) & 7) || headers_bytes < FIXED_HDR + comments_bytes ||
++ if (((headers_bytes + 4) & 7) ||
++ comments_bytes > 0x40000000 || /* max 1 GB */
++ headers_bytes < FIXED_HDR + comments_bytes ||
+ (num_channels > 65535)) /* Reserve top 16 bits */ {
+ lsx_fail_errno(ft, SOX_EHDR, "invalid sox file format header");
+ return SOX_EOF;
+--
+2.25.0
+
diff --git a/legacy/sox/CVE-2019-8354.patch b/legacy/sox/CVE-2019-8354.patch
new file mode 100644
index 000000000..1fa0e669f
--- /dev/null
+++ b/legacy/sox/CVE-2019-8354.patch
@@ -0,0 +1,28 @@
+From f70911261a84333b077c29908e1242f69d7439eb Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans@mansr.com>
+Date: Wed, 24 Apr 2019 14:57:34 +0100
+Subject: [PATCH] fix possible buffer size overflow in lsx_make_lpf()
+ (CVE-2019-8354)
+
+The multiplication in the size argument malloc() might overflow,
+resulting in a small buffer being allocated. Use calloc() instead.
+---
+ src/effects_i_dsp.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/effects_i_dsp.c b/src/effects_i_dsp.c
+index a979b501..e32dfa05 100644
+--- a/src/effects_i_dsp.c
++++ b/src/effects_i_dsp.c
+@@ -357,7 +357,7 @@ double * lsx_make_lpf(int num_taps, double Fc, double beta, double rho,
+ double scale, sox_bool dc_norm)
+ {
+ int i, m = num_taps - 1;
+- double * h = malloc(num_taps * sizeof(*h)), sum = 0;
++ double * h = calloc(num_taps, sizeof(*h)), sum = 0;
+ double mult = scale / lsx_bessel_I_0(beta), mult1 = 1 / (.5 * m + rho);
+ assert(Fc >= 0 && Fc <= 1);
+ lsx_debug("make_lpf(n=%i Fc=%.7g β=%g ρ=%g dc-norm=%i scale=%g)", num_taps, Fc, beta, rho, dc_norm, scale);
+--
+2.25.0
+
diff --git a/legacy/sox/CVE-2019-8355.patch b/legacy/sox/CVE-2019-8355.patch
new file mode 100644
index 000000000..d4d8cb808
--- /dev/null
+++ b/legacy/sox/CVE-2019-8355.patch
@@ -0,0 +1,59 @@
+Backport of the following:
+
+From ec073861aa9c0f779a3741c456e4f97d59366ffb Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans@mansr.com>
+Date: Sun, 5 Nov 2017 15:40:16 +0000
+Subject: [PATCH] make: update exported symbol list [bug #266]
+
+From f8587e2d50dad72d40453ac1191c539ee9e50381 Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans@mansr.com>
+Date: Wed, 24 Apr 2019 17:39:45 +0100
+Subject: [PATCH] fix possible overflow in lsx_(re)valloc() size calculation
+ (CVE-2019-8355)
+
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -95,7 +95,7 @@ libsox_la_LIBADD += @GOMP_LIBS@
+
+ libsox_la_CFLAGS = @WARN_CFLAGS@
+ libsox_la_LDFLAGS = @APP_LDFLAGS@ -version-info @SHLIB_VERSION@ \
+- -export-symbols-regex '^(sox_.*|lsx_(check_read_params|(close|open)_dllibrary|(debug(_more|_most)?|fail|report|warn)_impl|eof|fail_errno|filelength|find_(enum_(text|value)|file_extension)|getopt(_init)?|lpc10_(create_(de|en)coder_state|(de|en)code)|raw(read|write)|read(_b_buf|buf|chars)|realloc|rewind|seeki|sigfigs3p?|strcasecmp|tell|unreadb|write(b|_b_buf|buf|s)))$$'
++ -export-symbols-regex '^(sox_.*|lsx_(([cm]|re)alloc.*|check_read_params|(close|open)_dllibrary|(debug(_more|_most)?|fail|report|warn)_impl|eof|error|fail_errno|filelength|find_(enum_(text|value)|file_extension)|flush|getopt(_init)?|lpc10_(create_(de|en)coder_state|(de|en)code)|raw(read|write)|read(_b_buf|buf|chars)|rewind|seeki|sigfigs3p?|strcasecmp|strdup|tell|unreadb|write(b|_b_buf|buf|s)))$$'
+
+ if HAVE_WIN32_LTDL
+ libsox_la_SOURCES += win32-ltdl.c win32-ltdl.h
+--- sox-14.4.2/src/xmalloc.c 2012-01-23 16:27:33.000000000 -0600
++++ sox-14.4.2/src/xmalloc.c 2020-03-21 13:24:52.660007611 -0500
+@@ -41,3 +41,13 @@ void *lsx_realloc(void *ptr, size_t news
+
+ return ptr;
+ }
++
++void *lsx_realloc_array(void *p, size_t n, size_t size)
++{
++ if (n > (size_t)-1 / size) {
++ lsx_fail("malloc size overflow");
++ exit(2);
++ }
++
++ return lsx_realloc(p, n * size);
++}
+--- sox-14.4.2/src/xmalloc.h 2012-01-23 16:27:33.000000000 -0600
++++ sox-14.4.2/src/xmalloc.h 2020-03-21 13:24:14.610007203 -0500
+@@ -23,12 +23,14 @@
+ #include <stddef.h>
+ #include <string.h>
+
++LSX_RETURN_VALID void *lsx_realloc_array(void *p, size_t n, size_t size);
++
+ #define lsx_malloc(size) lsx_realloc(NULL, (size))
+ #define lsx_calloc(n,s) (((n)*(s))? memset(lsx_malloc((n)*(s)),0,(n)*(s)) : NULL)
+ #define lsx_Calloc(v,n) v = lsx_calloc(n,sizeof(*(v)))
+ #define lsx_strdup(p) ((p)? strcpy((char *)lsx_malloc(strlen(p) + 1), p) : NULL)
+ #define lsx_memdup(p,s) ((p)? memcpy(lsx_malloc(s), p, s) : NULL)
+-#define lsx_valloc(v,n) v = lsx_malloc((n)*sizeof(*(v)))
+-#define lsx_revalloc(v,n) v = lsx_realloc(v, (n)*sizeof(*(v)))
++#define lsx_valloc(v,n) v = lsx_realloc_array(NULL, n, sizeof(*(v)))
++#define lsx_revalloc(v,n) v = lsx_realloc_array(v, n, sizeof(*(v)))
+
+ #endif
diff --git a/legacy/sox/CVE-2019-8356.patch b/legacy/sox/CVE-2019-8356.patch
new file mode 100644
index 000000000..9375bc5ae
--- /dev/null
+++ b/legacy/sox/CVE-2019-8356.patch
@@ -0,0 +1,92 @@
+From b7883ae1398499daaa926ae6621f088f0f531ed8 Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans@mansr.com>
+Date: Wed, 24 Apr 2019 16:56:42 +0100
+Subject: [PATCH] fft4g: bail if size too large (CVE-2019-8356)
+
+Prevent overflowing of fixed-size buffers in bitrv2() and bitrv2conj()
+if the transform size is too large.
+---
+ src/fft4g.c | 18 ++++++++++++++++++
+ src/fft4g.h | 2 ++
+ 2 files changed, 20 insertions(+)
+
+diff --git a/src/fft4g.c b/src/fft4g.c
+index 38a8bcc0..88a2a7ec 100644
+--- a/src/fft4g.c
++++ b/src/fft4g.c
+@@ -322,6 +322,9 @@ static void rftfsub(int n, double *a, int nc, double const *c);
+
+ void cdft(int n, int isgn, double *a, int *ip, double *w)
+ {
++ if (n > FFT4G_MAX_SIZE)
++ return;
++
+ if (n > (ip[0] << 2)) {
+ makewt(n >> 2, ip, w);
+ }
+@@ -344,6 +347,9 @@ void rdft(int n, int isgn, double *a, int *ip, double *w)
+ int nw, nc;
+ double xi;
+
++ if (n > FFT4G_MAX_SIZE)
++ return;
++
+ nw = ip[0];
+ if (n > (nw << 2)) {
+ nw = n >> 2;
+@@ -384,6 +390,9 @@ void ddct(int n, int isgn, double *a, int *ip, double *w)
+ int j, nw, nc;
+ double xr;
+
++ if (n > FFT4G_MAX_SIZE)
++ return;
++
+ nw = ip[0];
+ if (n > (nw << 2)) {
+ nw = n >> 2;
+@@ -435,6 +444,9 @@ void ddst(int n, int isgn, double *a, int *ip, double *w)
+ int j, nw, nc;
+ double xr;
+
++ if (n > FFT4G_MAX_SIZE)
++ return;
++
+ nw = ip[0];
+ if (n > (nw << 2)) {
+ nw = n >> 2;
+@@ -486,6 +498,9 @@ void dfct(int n, double *a, double *t, int *ip, double *w)
+ int j, k, l, m, mh, nw, nc;
+ double xr, xi, yr, yi;
+
++ if (n > FFT4G_MAX_SIZE)
++ return;
++
+ nw = ip[0];
+ if (n > (nw << 3)) {
+ nw = n >> 3;
+@@ -576,6 +591,9 @@ void dfst(int n, double *a, double *t, int *ip, double *w)
+ int j, k, l, m, mh, nw, nc;
+ double xr, xi, yr, yi;
+
++ if (n > FFT4G_MAX_SIZE)
++ return;
++
+ nw = ip[0];
+ if (n > (nw << 3)) {
+ nw = n >> 3;
+diff --git a/src/fft4g.h b/src/fft4g.h
+index 2b8051ca..95ee3413 100644
+--- a/src/fft4g.h
++++ b/src/fft4g.h
+@@ -13,6 +13,8 @@
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
++#define FFT4G_MAX_SIZE 262144
++
+ void lsx_cdft(int, int, double *, int *, double *);
+ void lsx_rdft(int, int, double *, int *, double *);
+ void lsx_ddct(int, int, double *, int *, double *);
+--
+2.25.0
+
diff --git a/legacy/sox/CVE-2019-8357.patch b/legacy/sox/CVE-2019-8357.patch
new file mode 100644
index 000000000..ec2b04d30
--- /dev/null
+++ b/legacy/sox/CVE-2019-8357.patch
@@ -0,0 +1,28 @@
+From 2ce02fea7b350de9ddfbcf542ba4dd59a8ab255b Mon Sep 17 00:00:00 2001
+From: Mans Rullgard <mans@mansr.com>
+Date: Wed, 24 Apr 2019 15:08:51 +0100
+Subject: [PATCH] fix possible null pointer deref in lsx_make_lpf()
+ (CVE-2019-8357)
+
+If the buffer allocation fails, return NULL.
+---
+ src/effects_i_dsp.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/effects_i_dsp.c b/src/effects_i_dsp.c
+index e32dfa05..88b1b390 100644
+--- a/src/effects_i_dsp.c
++++ b/src/effects_i_dsp.c
+@@ -362,6 +362,9 @@ double * lsx_make_lpf(int num_taps, double Fc, double beta, double rho,
+ assert(Fc >= 0 && Fc <= 1);
+ lsx_debug("make_lpf(n=%i Fc=%.7g β=%g ρ=%g dc-norm=%i scale=%g)", num_taps, Fc, beta, rho, dc_norm, scale);
+
++ if (!h)
++ return NULL;
++
+ for (i = 0; i <= m / 2; ++i) {
+ double z = i - .5 * m, x = z * M_PI, y = z * mult1;
+ h[i] = x? sin(Fc * x) / x : Fc;
+--
+2.25.0
+
diff --git a/legacy/sox/disable-pipe-file-detection.patch b/legacy/sox/disable-pipe-file-detection.patch
new file mode 100644
index 000000000..3d2a854f7
--- /dev/null
+++ b/legacy/sox/disable-pipe-file-detection.patch
@@ -0,0 +1,11 @@
+--- sox-14.4.2/src/formats.c.old 2014-10-27 02:55:50.000000000 +0000
++++ sox-14.4.2/src/formats.c 2018-07-22 04:36:34.380000000 +0000
+@@ -422,7 +422,7 @@
+ /* To fix this #error, either simply remove the #error line and live without
+ * file-type detection with pipes, or add support for your compiler in the
+ * lines above. Test with cat monkey.wav | ./sox --info - */
+- #error FIX NEEDED HERE
++ /* #error FIX NEEDED HERE */
+ #define NO_REWIND_PIPE
+ (void)fp;
+ #endif