diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-04-20 21:52:18 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-04-20 22:08:28 +0200 |
commit | a5379d6e68cbdd894941d7962e72af890d41d1b7 (patch) | |
tree | f99efbdf46ff96dc681d378d2217a69dad62868e /libavcodec/flac_parser.c | |
parent | 5a14fca9aacaf9ad4fd6b30792463949180e4300 (diff) | |
parent | b18346817d57c96cc47811cf78b26653e96bd304 (diff) | |
download | ffmpeg-a5379d6e68cbdd894941d7962e72af890d41d1b7.tar.gz |
Merge commit 'b18346817d57c96cc47811cf78b26653e96bd304'
* commit 'b18346817d57c96cc47811cf78b26653e96bd304':
flac: fix realloc loop with invalid flac files
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/flac_parser.c')
-rw-r--r-- | libavcodec/flac_parser.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c index 12e09bb55e..3723716441 100644 --- a/libavcodec/flac_parser.c +++ b/libavcodec/flac_parser.c @@ -615,6 +615,15 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx, nb_desired * FLAC_AVG_FRAME_SIZE); } + if (!av_fifo_space(fpc->fifo_buf) && + av_fifo_size(fpc->fifo_buf) / FLAC_AVG_FRAME_SIZE > + fpc->nb_headers_buffered * 10) { + /* There is less than one valid flac header buffered for 10 headers + * buffered. Therefore the fifo is most likely filled with invalid + * data and the input is not a flac file. */ + goto handle_error; + } + /* Fill the buffer. */ if ( av_fifo_space(fpc->fifo_buf) < read_end - read_start && av_fifo_realloc2(fpc->fifo_buf, (read_end - read_start) + 2*av_fifo_size(fpc->fifo_buf)) < 0) { |