Skip to content

Commit a2e9eab

Browse files
committed
Actually fail when error occurs in parseFormat
When there's an unsupported number of bits per sample or an invalid number of samples per block, don't only print an error message using the error handler, but actually stop parsing the file. This fixes mpruett#35 (also reported at https://bugzilla.opensuse.org/show_bug.cgi?id=1026983 and https://blogs.gentoo.org/ago/2017/02/20/audiofile-heap-based-buffer-overflow-in-imadecodeblockwave-ima-cpp/ )
1 parent b62c902 commit a2e9eab

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: libaudiofile/WAVE.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,15 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
326326
{
327327
_af_error(AF_BAD_NOT_IMPLEMENTED,
328328
"IMA ADPCM compression supports only 4 bits per sample");
329+
return AF_FAIL;
329330
}
330331

331332
int bytesPerBlock = (samplesPerBlock + 14) / 8 * 4 * channelCount;
332333
if (bytesPerBlock > blockAlign || (samplesPerBlock % 8) != 1)
333334
{
334335
_af_error(AF_BAD_CODEC_CONFIG,
335336
"Invalid samples per block for IMA ADPCM compression");
337+
return AF_FAIL;
336338
}
337339

338340
track->f.sampleWidth = 16;

0 commit comments

Comments
 (0)