ref: 8c2be5c74c6d10b1470812a8c9d0db88a595cc8b
parent: 37e998b098e802cdf94ad31d97f3a0038d2d1900
author: Mans Rullgard <mans@mansr.com>
date: Fri Apr 27 14:49:42 EDT 2018
wav: adpcm: stricter header validation [bug #265] 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.
--- a/src/wav.c
+++ b/src/wav.c
@@ -766,7 +766,7 @@
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);
@@ -823,7 +823,7 @@
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);