Mercurial > hg > octave-nkf
changeset 15530:203c78063bff
Fix wavread to support truncated files (bug #37532)
* wavread.m: Limit chunk sizes by the total size of the input file.
author | Mike Miller <mtmiller@ieee.org> |
---|---|
date | Mon, 15 Oct 2012 21:44:52 -0400 |
parents | 9a7f73fc304f |
children | 39fd2ad26fb7 |
files | scripts/audio/wavread.m |
diffstat | 1 files changed, 2 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/audio/wavread.m +++ b/scripts/audio/wavread.m @@ -76,6 +76,7 @@ if (riff_size == -1) error ("wavread: file contains no RIFF chunk"); endif + riff_size = min (riff_size, file_size - riff_pos); riff_type = char (fread (fid, 4))'; if (! strcmp (riff_type, "WAVE")) @@ -100,6 +101,7 @@ if (data_size == -1) error ("wavread: file contains no data chunk"); endif + data_size = min (data_size, file_size - data_pos); ### Read format chunk. fseek (fid, fmt_pos, "bof");