From: Michael Niedermayer <michael@niedermayer.cc> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/fmvc: Require key frames to fill a non trivial part of the buffer Date: Sat, 11 Jun 2022 01:10:45 +0200 Message-ID: <20220610231045.9760-3-michael@niedermayer.cc> (raw) In-Reply-To: <20220610231045.9760-1-michael@niedermayer.cc> Keyframes filling only part of the buffer should theoretically be invalid as they are not really keyframes. Fixes: Timeout Fixes: 47879/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FMVC_fuzzer-6258764937822208 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavcodec/fmvc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavcodec/fmvc.c b/libavcodec/fmvc.c index de2bf828f4..36990956e0 100644 --- a/libavcodec/fmvc.c +++ b/libavcodec/fmvc.c @@ -284,7 +284,7 @@ static int decode_type2(GetByteContext *gb, PutByteContext *pb) } } - return 0; + return bytestream2_get_bytes_left_p(pb); } static int decode_type1(GetByteContext *gb, PutByteContext *pb) @@ -391,7 +391,7 @@ static int decode_type1(GetByteContext *gb, PutByteContext *pb) } while (len && bytestream2_get_bytes_left(&gbc) > 0); } - return 0; + return bytestream2_get_bytes_left_p(pb); } static int decode_frame(AVCodecContext *avctx, AVFrame *frame, @@ -414,6 +414,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, if (key_frame) { const uint8_t *src; unsigned type, size; + int left; uint8_t *dst; type = bytestream2_get_le16(gb); @@ -423,14 +424,17 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *frame, bytestream2_init_writer(pb, s->buffer, s->buffer_size); if (type == 1) { - decode_type1(gb, pb); + left = decode_type1(gb, pb); } else if (type == 2){ - decode_type2(gb, pb); + left = decode_type2(gb, pb); } else { avpriv_report_missing_feature(avctx, "Compression type %d", type); return AVERROR_PATCHWELCOME; } + if (left > s->buffer_size*4/5) + return AVERROR_INVALIDDATA; + if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; -- 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-06-10 23:12 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-10 23:10 [FFmpeg-devel] [PATCH 1/3] avcodec/fmvc: Move frame allocation to a later stage Michael Niedermayer 2022-06-10 23:10 ` [FFmpeg-devel] [PATCH 2/3] avcodec/fmvc: buffer size is stride based not 4*width Michael Niedermayer 2022-06-11 8:47 ` Paul B Mahol 2022-06-11 14:55 ` Michael Niedermayer 2022-06-13 8:04 ` Paul B Mahol 2022-06-13 9:10 ` Anton Khirnov 2022-06-13 9:34 ` Paul B Mahol 2022-06-13 9:47 ` Anton Khirnov 2022-06-13 10:10 ` Paul B Mahol 2022-06-13 19:13 ` Michael Niedermayer 2022-09-02 16:31 ` Michael Niedermayer 2022-09-02 16:48 ` Paul B Mahol 2022-09-04 21:42 ` Michael Niedermayer 2022-09-08 20:54 ` Michael Niedermayer 2022-06-10 23:10 ` Michael Niedermayer [this message] 2022-09-08 20:52 ` [FFmpeg-devel] [PATCH 1/3] avcodec/fmvc: Move frame allocation to a later stage Michael Niedermayer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220610231045.9760-3-michael@niedermayer.cc \ --to=michael@niedermayer.cc \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git