* [PATCH] wav: adpcm: stricter header validation
@ 2018-04-27 17:50 Mans Rullgard
0 siblings, 0 replies; only message in thread
From: Mans Rullgard @ 2018-04-27 17:50 UTC (permalink / raw)
To: sox-devel
If the samples per block and block align values do not match, the
file is invalid and decoding will likely fail. Abort in this case
rather than returning garbage or crashing later.
---
src/wav.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/wav.c b/src/wav.c
index 5202556c0e31..3b07e5e25fd3 100644
--- a/src/wav.c
+++ b/src/wav.c
@@ -760,7 +760,7 @@ static int startread(sox_format_t * ft)
lsx_readw(ft, &(wav->samplesPerBlock));
bytesPerBlock = lsx_ms_adpcm_bytes_per_block((size_t) ft->signal.channels, (size_t) wav->samplesPerBlock);
- if (bytesPerBlock > wav->blockAlign)
+ if (bytesPerBlock != wav->blockAlign)
{
lsx_fail_errno(ft,SOX_EOF,"format[%s]: samplesPerBlock(%d) incompatible with blockAlign(%d)",
wav_format_str(wav->formatTag), wav->samplesPerBlock, wav->blockAlign);
@@ -816,7 +816,7 @@ static int startread(sox_format_t * ft)
lsx_readw(ft, &(wav->samplesPerBlock));
bytesPerBlock = lsx_ima_bytes_per_block((size_t) ft->signal.channels, (size_t) wav->samplesPerBlock);
- if (bytesPerBlock > wav->blockAlign || wav->samplesPerBlock%8 != 1)
+ if (bytesPerBlock != wav->blockAlign || wav->samplesPerBlock%8 != 1)
{
lsx_fail_errno(ft,SOX_EOF,"format[%s]: samplesPerBlock(%d) incompatible with blockAlign(%d)",
wav_format_str(wav->formatTag), wav->samplesPerBlock, wav->blockAlign);
--
2.17.0
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-04-27 17:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-27 17:50 [PATCH] wav: adpcm: stricter header validation Mans Rullgard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).