mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-27 03:50:29 +00:00
src/sndfile.c : Add code to prevent sf_read_raw from reading past the end of the audio data.
This commit is contained in:
parent
e81a508411
commit
fecb5c56eb
@ -6,8 +6,13 @@
|
||||
Remove redundant code.
|
||||
|
||||
* tests/lossy_comp_test.c
|
||||
Add raw_read_test to check that raw reads do not go past the end of the
|
||||
audio data section.
|
||||
Clean up error output messages.
|
||||
|
||||
* src/sndfile.c
|
||||
Add code to prevent sf_read_raw from reading past the end of the audio data.
|
||||
|
||||
2007-11-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* configure.ac src/Makefile.am src/create_symbols_file.py
|
||||
|
@ -1274,7 +1274,7 @@ sf_set_string (SNDFILE *sndfile, int str_type, const char* str)
|
||||
sf_count_t
|
||||
sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes)
|
||||
{ SF_PRIVATE *psf ;
|
||||
sf_count_t count ;
|
||||
sf_count_t count, extra ;
|
||||
int bytewidth, blockwidth ;
|
||||
|
||||
VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf, 1) ;
|
||||
@ -1299,10 +1299,14 @@ sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes)
|
||||
|
||||
count = psf_fread (ptr, 1, bytes, psf) ;
|
||||
|
||||
if (count < bytes)
|
||||
psf_memset (((char*) ptr) + count, 0, bytes - count) ;
|
||||
|
||||
psf->read_current += count / blockwidth ;
|
||||
if (psf->read_current + count / blockwidth <= psf->sf.frames)
|
||||
psf->read_current += count / blockwidth ;
|
||||
else
|
||||
{ count = (psf->sf.frames - psf->read_current) * blockwidth ;
|
||||
extra = bytes - count ;
|
||||
psf_memset (((char *) ptr) + count, 0, extra) ;
|
||||
psf->read_current = psf->sf.frames ;
|
||||
} ;
|
||||
|
||||
psf->last_op = SFM_READ ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user