| 1 | From: Antonio Larrosa <[email protected]>
|
| 2 | Date: Mon, 6 Mar 2017 18:59:26 +0100
|
| 3 | Subject: Actually fail when error occurs in parseFormat
|
| 4 |
|
| 5 | When there's an unsupported number of bits per sample or an invalid
|
| 6 | number of samples per block, don't only print an error message using
|
| 7 | the error handler, but actually stop parsing the file.
|
| 8 |
|
| 9 | This fixes #35 (also reported at
|
| 10 | https://bugzilla.opensuse.org/show_bug.cgi?id=1026983 and
|
| 11 | https://blogs.gentoo.org/ago/2017/02/20/audiofile-heap-based-buffer-overflow-in-imadecodeblockwave-ima-cpp/
|
| 12 | )
|
| 13 | ---
|
| 14 | libaudiofile/WAVE.cpp | 2 ++
|
| 15 | 1 file changed, 2 insertions(+)
|
| 16 |
|
| 17 | diff --git a/libaudiofile/WAVE.cpp b/libaudiofile/WAVE.cpp
|
| 18 | index 0fc48e8..d04b796 100644
|
| 19 | |
| 20 | |
| 21 | @@ -332,6 +332,7 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
|
| 22 | {
|
| 23 | _af_error(AF_BAD_NOT_IMPLEMENTED,
|
| 24 | "IMA ADPCM compression supports only 4 bits per sample");
|
| 25 | + return AF_FAIL;
|
| 26 | }
|
| 27 |
|
| 28 | int bytesPerBlock = (samplesPerBlock + 14) / 8 * 4 * channelCount;
|
| 29 | @@ -339,6 +340,7 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
|
| 30 | {
|
| 31 | _af_error(AF_BAD_CODEC_CONFIG,
|
| 32 | "Invalid samples per block for IMA ADPCM compression");
|
| 33 | + return AF_FAIL;
|
| 34 | }
|
| 35 |
|
| 36 | track->f.sampleWidth = 16;
|