Re: [FFmpeg-devel] [PATCH 2/5] avcodec/vc1_block: Check for end of bitstream at the top of vc1_decode_i_blocks_adv()

2019-11-09 Thread Michael Niedermayer
On Sun, Sep 29, 2019 at 01:53:42AM +0200, Michael Niedermayer wrote:
> Fixes: Timeout (147sec -> 2sec)
> Fixes: 
> 17704/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5723851098423296
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vc1_block.c | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

will apply

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/5] avcodec/vc1_block: Check for end of bitstream at the top of vc1_decode_i_blocks_adv()

2019-09-28 Thread Michael Niedermayer
Fixes: Timeout (147sec -> 2sec)
Fixes: 
17704/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1IMAGE_fuzzer-5723851098423296

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vc1_block.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index e293a4..e43856037a 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -2661,7 +2661,7 @@ static void vc1_decode_i_blocks(VC1Context *v)
 
 /** Decode blocks of I-frame for advanced profile
  */
-static void vc1_decode_i_blocks_adv(VC1Context *v)
+static int vc1_decode_i_blocks_adv(VC1Context *v)
 {
 int k;
 MpegEncContext *s = &v->s;
@@ -2672,6 +2672,9 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
 int mqdiff;
 GetBitContext *gb = &s->gb;
 
+if (get_bits_left(gb) <= 1)
+return AVERROR_INVALIDDATA;
+
 /* select coding mode used for VLC tables selection */
 switch (v->y_ac_table_index) {
 case 0:
@@ -2775,7 +2778,7 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
 ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, 
ER_MB_ERROR);
 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > 
%i\n",
get_bits_count(&s->gb), v->bits);
-return;
+return 0;
 }
 inc_blk_idx(v->topleft_blk_idx);
 inc_blk_idx(v->top_blk_idx);
@@ -2793,6 +2796,7 @@ static void vc1_decode_i_blocks_adv(VC1Context *v)
 ff_mpeg_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
 ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
 (s->end_mb_y << v->field_mode) - 1, ER_MB_END);
+return 0;
 }
 
 static void vc1_decode_p_blocks(VC1Context *v)
-- 
2.23.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".