mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-13 15:12:30 -05:00
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
This commit is contained in:
parent
271441eb9d
commit
516693fcc9
4 changed files with 81 additions and 49 deletions
|
|
@ -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--;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue