cherry-pick audio/sox patches from git fixing problems with some bad input.

ok jasper@, Jan Stary
This commit is contained in:
sthen 2014-12-29 10:44:55 +00:00
parent 38505fca32
commit f89e855560
4 changed files with 57 additions and 1 deletions

View File

@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.57 2014/10/14 15:56:59 schwarze Exp $
# $OpenBSD: Makefile,v 1.58 2014/12/29 10:44:55 sthen Exp $
COMMENT= Sound eXchange, the Swiss Army knife of audio manipulation
DISTNAME= sox-14.4.1
REVISION= 0
SHARED_LIBS += sox 3.0 # .2.1
CATEGORIES= audio

View File

@ -0,0 +1,18 @@
$OpenBSD: patch-src_gain_c,v 1.1 2014/12/29 10:44:55 sthen Exp $
[1c3d52] prevent division by 0 when input signal is entirely non-negative,
non-positive, or both
--- src/gain.c.orig Wed Dec 24 12:32:38 2014
+++ src/gain.c Wed Dec 24 12:32:53 2014
@@ -80,7 +80,9 @@ static int start(sox_effect_t * effp)
if (!p->do_equalise && !p->do_balance && !p->do_balance_no_clip)
effp->flows = 1; /* essentially a conditional SOX_EFF_MCHAN */
}
- p->mult = p->max = p->min = 0;
+ p->mult = 0;
+ p->max = 1;
+ p->min = -1;
if (p->do_scan) {
p->tmp_file = lsx_tmpfile();
if (p->tmp_file == NULL) {

View File

@ -0,0 +1,18 @@
$OpenBSD: patch-src_sphere_c,v 1.3 2014/12/29 10:44:55 sthen Exp $
[7d3f38] Check for minimum size sphere headers
--- src/sphere.c.orig Wed Dec 24 12:31:33 2014
+++ src/sphere.c Wed Dec 24 12:31:53 2014
@@ -47,6 +47,11 @@ static int start_read(sox_format_t * ft)
/* Determine header size, and allocate a buffer large enough to hold it. */
sscanf(fldsval, "%lu", &header_size_ul);
+ if (header_size_ul < 16) {
+ lsx_fail_errno(ft, SOX_EHDR, "Error reading Sphere header");
+ return (SOX_EOF);
+ }
+
buf = lsx_malloc(header_size = header_size_ul);
/* Skip what we have read so far */

View File

@ -0,0 +1,19 @@
$OpenBSD: patch-src_wav_c,v 1.1 2014/12/29 10:44:55 sthen Exp $
[f39c57] More checks for invalid MS ADPCM blocks.
If block doesn't exacty match blockAlign then do not allow
number of samples in invalid size block to ever be more than
what WAV header defined as samplesPerBlock.
--- src/wav.c.orig Wed Dec 24 12:33:35 2014
+++ src/wav.c Wed Dec 24 12:33:54 2014
@@ -166,7 +166,7 @@ static unsigned short AdpcmReadBlock(sox_format_t * f
/* work with partial blocks. Specs say it should be null */
/* padded but I guess this is better than trailing quiet. */
samplesThisBlock = lsx_ms_adpcm_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;