diff options
author | Dave Bryant <bryant@rockbox.org> | 2010-12-05 19:25:32 +0000 |
---|---|---|
committer | Dave Bryant <bryant@rockbox.org> | 2010-12-05 19:25:32 +0000 |
commit | 516693fcc9a35eeae86422a17ac9d2be4bbe899c (patch) | |
tree | 7343dcda98f60cca9ecfc47f37310a2d4822d2d9 /apps/codecs/libwavpack/metadata.c | |
parent | 271441eb9d568525a72cde810a64b63db5a39147 (diff) |
make WavPack library check the extent of the block that it is parsing so that it cannot run into the next block; also enhance the metadata code to handle the case of files with non-audio blocks at the beginning (which can happen if the source WAV file has lots of RIFF data)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28736 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libwavpack/metadata.c')
-rw-r--r-- | apps/codecs/libwavpack/metadata.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/apps/codecs/libwavpack/metadata.c b/apps/codecs/libwavpack/metadata.c index c944093b19..4dce10100f 100644 --- a/apps/codecs/libwavpack/metadata.c +++ b/apps/codecs/libwavpack/metadata.c @@ -19,15 +19,16 @@ int read_metadata_buff (WavpackContext *wpc, WavpackMetadata *wpmd) uint32_t bytes_to_read; uchar tchar; - if (!wpc->infile (&wpmd->id, 1) || !wpc->infile (&tchar, 1)) + if (wpc->stream.block_bytes_left < 2 || !wpc->infile (&wpmd->id, 1) || !wpc->infile (&tchar, 1)) return FALSE; wpmd->byte_length = tchar << 1; + wpc->stream.block_bytes_left -= 2; if (wpmd->id & ID_LARGE) { wpmd->id &= ~ID_LARGE; - if (!wpc->infile (&tchar, 1)) + if (wpc->stream.block_bytes_left < 2 || !wpc->infile (&tchar, 1)) return FALSE; wpmd->byte_length += (int32_t) tchar << 9; @@ -36,8 +37,12 @@ int read_metadata_buff (WavpackContext *wpc, WavpackMetadata *wpmd) return FALSE; wpmd->byte_length += (int32_t) tchar << 17; + wpc->stream.block_bytes_left -= 2; } + if ((wpc->stream.block_bytes_left -= wpmd->byte_length) < 0) + return FALSE; + if (wpmd->id & ID_ODD_SIZE) { wpmd->id &= ~ID_ODD_SIZE; wpmd->byte_length--; |