summary refs log tree commit diff
path: root/pkgs/applications/misc/audio/sox/0002-More-checks-for-invalid-MS-ADPCM-blocks.patch
blob: 72c2d765a945dbcc868e316bae2c7360cbd1e5fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
From ebb64cddde59ecc9cedf3741ce2337c72148cc0c Mon Sep 17 00:00:00 2001
From: Chris Bagwell <chris@cnpbagwell.com>
Date: Sat, 13 Dec 2014 12:49:55 -0600
Subject: [PATCH 2/2] 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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/wav.c b/src/wav.c
index 61d5908..5202556 100644
--- a/src/wav.c
+++ b/src/wav.c
@@ -168,7 +168,7 @@ static unsigned short  AdpcmReadBlock(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_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;
-- 
2.1.0