mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 09:59:54 +00:00
src/ : Rationalize and improve error handling when parsing 'fmt ' chunk of WAV/W64/RF64 files.
This commit is contained in:
parent
9980dea160
commit
00b257f771
@ -9,6 +9,9 @@
|
||||
* src/rf64.c
|
||||
Add code to prevent infinite loop on malformed file.
|
||||
|
||||
* src/common.h src/sndfile.c src/w64.c src/wav_w64.c
|
||||
Rationalize and improve error handling when parsing 'fmt ' chunk.
|
||||
|
||||
2008-10-26 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* programs/common.c
|
||||
|
@ -466,6 +466,7 @@ enum
|
||||
SFE_WAV_NO_RIFF,
|
||||
SFE_WAV_NO_WAVE,
|
||||
SFE_WAV_NO_FMT,
|
||||
SFE_WAV_BAD_FMT,
|
||||
SFE_WAV_FMT_SHORT,
|
||||
SFE_WAV_BAD_FACT,
|
||||
SFE_WAV_BAD_PEAK,
|
||||
@ -534,10 +535,7 @@ enum
|
||||
SFE_W64_64_BIT,
|
||||
SFE_W64_NO_RIFF,
|
||||
SFE_W64_NO_WAVE,
|
||||
SFE_W64_NO_FMT,
|
||||
SFE_W64_NO_DATA,
|
||||
SFE_W64_FMT_SHORT,
|
||||
SFE_W64_FMT_TOO_BIG,
|
||||
SFE_W64_ADPCM_NOT4BIT,
|
||||
SFE_W64_ADPCM_CHANNELS,
|
||||
SFE_W64_GSM610_FORMAT,
|
||||
|
@ -124,8 +124,9 @@ ErrorStruct SndfileErrors [] =
|
||||
|
||||
{ SFE_WAV_NO_RIFF , "Error in WAV file. No 'RIFF' chunk marker." },
|
||||
{ SFE_WAV_NO_WAVE , "Error in WAV file. No 'WAVE' chunk marker." },
|
||||
{ SFE_WAV_NO_FMT , "Error in WAV file. No 'fmt ' chunk marker." },
|
||||
{ SFE_WAV_FMT_SHORT , "Error in WAV file. Short 'fmt ' chunk." },
|
||||
{ SFE_WAV_NO_FMT , "Error in WAV/W64/RF64 file. No 'fmt ' chunk marker." },
|
||||
{ SFE_WAV_BAD_FMT , "Error in WAV/W64/RF64 file. Malformed 'fmt ' chunk." },
|
||||
{ SFE_WAV_FMT_SHORT , "Error in WAV/W64/RF64 file. Short 'fmt ' chunk." },
|
||||
|
||||
{ SFE_WAV_BAD_FACT , "Error in WAV file. 'fact' chunk out of place." },
|
||||
{ SFE_WAV_BAD_PEAK , "Error in WAV file. Bad 'PEAK' chunk." },
|
||||
@ -196,15 +197,9 @@ ErrorStruct SndfileErrors [] =
|
||||
{ SFE_IRCAM_UNKNOWN_FORMAT, "Error in IRCAM file, unknow encoding format." },
|
||||
|
||||
{ SFE_W64_64_BIT , "Error in W64 file, file contains 64 bit offset." },
|
||||
|
||||
{ SFE_W64_NO_RIFF , "Error in W64 file. No 'riff' chunk marker." },
|
||||
{ SFE_W64_NO_WAVE , "Error in W64 file. No 'wave' chunk marker." },
|
||||
{ SFE_W64_NO_FMT , "Error in W64 file. No 'fmt ' chunk marker." },
|
||||
{ SFE_W64_NO_DATA , "Error in W64 file. No 'data' chunk marker." },
|
||||
|
||||
{ SFE_W64_FMT_SHORT , "Error in W64 file. Short 'fmt ' chunk." },
|
||||
{ SFE_W64_FMT_TOO_BIG , "Error in W64 file. 'fmt ' chunk too large." },
|
||||
|
||||
{ SFE_W64_ADPCM_NOT4BIT , "Error in ADPCM W64 file. Invalid bit width." },
|
||||
{ SFE_W64_ADPCM_CHANNELS , "Error in ADPCM W64 file. Invalid number of channels." },
|
||||
{ SFE_W64_GSM610_FORMAT , "Error in GSM610 W64 file. Invalid format chunk." },
|
||||
|
@ -270,7 +270,7 @@ w64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
|
||||
|
||||
case fmt_HASH16 :
|
||||
if ((parsestage & (HAVE_riff | HAVE_wave)) != (HAVE_riff | HAVE_wave))
|
||||
return SFE_W64_NO_FMT ;
|
||||
return SFE_WAV_NO_FMT ;
|
||||
|
||||
bytesread += psf_binheader_readf (psf, "e8", &chunk_size) ;
|
||||
psf_log_printf (psf, " fmt : %D\n", chunk_size) ;
|
||||
|
@ -345,12 +345,12 @@ wav_w64_read_fmt_chunk (SF_PRIVATE *psf, int fmtsize)
|
||||
|
||||
default :
|
||||
psf_log_printf (psf, "*** No 'fmt ' chunk dumper for this format!\n") ;
|
||||
break ;
|
||||
return SFE_WAV_BAD_FMT ;
|
||||
} ;
|
||||
|
||||
if (bytesread > fmtsize)
|
||||
{ psf_log_printf (psf, "*** wav_w64_read_fmt_chunk (bytesread > fmtsize)\n") ;
|
||||
return SFE_W64_FMT_SHORT ;
|
||||
return SFE_WAV_BAD_FMT ;
|
||||
}
|
||||
else
|
||||
psf_binheader_readf (psf, "j", fmtsize - bytesread) ;
|
||||
|
Loading…
Reference in New Issue
Block a user