diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2021-10-21 13:25:59 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2021-10-22 17:34:05 +0200 |
commit | 70024b6b47b9eacfe01e8f92349ca9bf1ccd7d5a (patch) | |
tree | ae7c46dd08d62811ffc0fead30d4f2a8d327e17f /libavcodec | |
parent | eda2a50c8e9381a357f936a190659bb039e0c038 (diff) | |
download | ffmpeg-70024b6b47b9eacfe01e8f92349ca9bf1ccd7d5a.tar.gz |
avcodec/flac_parser: Consider AV_INPUT_BUFFER_PADDING_SIZE
Fixes: out if array read
Fixes: 40109/clusterfuzz-testcase-minimized-ffmpeg_dem_FLAC_fuzzer-4805686811295744
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Mattias Wadman <mattias.wadman@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/flac_parser.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c index 2c550507fc..3b27b152fc 100644 --- a/libavcodec/flac_parser.c +++ b/libavcodec/flac_parser.c @@ -55,6 +55,7 @@ /** largest possible size of flac header */ #define MAX_FRAME_HEADER_SIZE 16 +#define MAX_FRAME_VERIFY_SIZE (MAX_FRAME_HEADER_SIZE + 1) typedef struct FLACHeaderMarker { int offset; /**< byte offset from start of FLACParseContext->buffer */ @@ -99,7 +100,7 @@ static int frame_header_is_valid(AVCodecContext *avctx, const uint8_t *buf, uint8_t subframe_type; // header plus one byte from first subframe - init_get_bits(&gb, buf, MAX_FRAME_HEADER_SIZE * 8 + 8); + init_get_bits(&gb, buf, MAX_FRAME_VERIFY_SIZE * 8); if (ff_flac_decode_frame_header(avctx, &gb, fi, 127)) { return 0; } @@ -196,7 +197,7 @@ static int find_headers_search_validate(FLACParseContext *fpc, int offset) uint8_t *header_buf; int size = 0; header_buf = flac_fifo_read_wrap(fpc, offset, - MAX_FRAME_HEADER_SIZE, + MAX_FRAME_VERIFY_SIZE + AV_INPUT_BUFFER_PADDING_SIZE, &fpc->wrap_buf, &fpc->wrap_buf_allocated_size); if (frame_header_is_valid(fpc->avctx, header_buf, &fi)) { |