[FFmpeg-devel,2/2] avcodec/diracdec: Count truncated parts as errors in decode_component()

Submitted by Michael Niedermayer on March 8, 2019, 4:38 p.m.

Details

Message ID 20190308163834.31692-2-michael@niedermayer.cc
State Accepted
Commit dd2a2a51fe47361fa82c67f2a417e1706713eaef
Headers show

Commit Message

Michael Niedermayer March 8, 2019, 4:38 p.m.
Fixes: Timeout (29sec -> 4sec)
Fixes: 13150/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5690185671507968

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/diracdec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer March 17, 2019, 10:39 a.m.
On Fri, Mar 08, 2019 at 05:38:34PM +0100, Michael Niedermayer wrote:
> Fixes: Timeout (29sec -> 4sec)
> Fixes: 13150/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5690185671507968
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/diracdec.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

will apply

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index 30b4bfad79..a1e759f656 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -685,7 +685,10 @@  static int decode_component(DiracContext *s, int comp)
                 }
                 align_get_bits(&s->gb);
                 b->coeff_data = s->gb.buffer + get_bits_count(&s->gb)/8;
-                b->length = FFMIN(b->length, FFMAX(get_bits_left(&s->gb)/8, 0));
+                if (b->length > FFMAX(get_bits_left(&s->gb)/8, 0)) {
+                    b->length = FFMAX(get_bits_left(&s->gb)/8, 0);
+                    damaged_count ++;
+                }
                 skip_bits_long(&s->gb, b->length*8);
             }
         }