diff mbox

[FFmpeg-devel,5/6] avcodec/4xm: Check for end of input in decode_p_block()

Message ID 20190812001719.9247-5-michael@niedermayer.cc
State Accepted
Commit 8f92eb05e063e6c4d6e36521020620d4e6e1c21d
Headers show

Commit Message

Michael Niedermayer Aug. 12, 2019, 12:17 a.m. UTC
Fixes: Timeout (81sec -> 0.2sec)
Fixes: 16169/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FOURXM_fuzzer-5662570416963584

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

Comments

Paul B Mahol Aug. 12, 2019, 9:53 a.m. UTC | #1
LGTM

On Mon, Aug 12, 2019 at 2:19 AM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> Fixes: Timeout (81sec -> 0.2sec)
> Fixes:
> 16169/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FOURXM_fuzzer-5662570416963584
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by
> <https://github.com/google/oss-fuzz/tree/master/projects/ffmpegSigned-off-by>:
> Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/4xm.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
> index 8382159bde..1f4e2aee24 100644
> --- a/libavcodec/4xm.c
> +++ b/libavcodec/4xm.c
> @@ -351,6 +351,8 @@ static int decode_p_block(FourXContext *f, uint16_t
> *dst, const uint16_t *src,
>      index = size2index[log2h][log2w];
>      av_assert0(index >= 0);
>
> +    if (get_bits_left(&f->gb) < 1)
> +        return AVERROR_INVALIDDATA;
>      h     = 1 << log2h;
>      code  = get_vlc2(&f->gb, block_type_vlc[1 - (f->version >
> 1)][index].table,
>                       BLOCK_TYPE_VLC_BITS, 1);
> --
> 2.22.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-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer Aug. 13, 2019, 9:30 a.m. UTC | #2
On Mon, Aug 12, 2019 at 11:53:20AM +0200, Paul B Mahol wrote:
> LGTM

will apply

thanks

[...]
diff mbox

Patch

diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index 8382159bde..1f4e2aee24 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -351,6 +351,8 @@  static int decode_p_block(FourXContext *f, uint16_t *dst, const uint16_t *src,
     index = size2index[log2h][log2w];
     av_assert0(index >= 0);
 
+    if (get_bits_left(&f->gb) < 1)
+        return AVERROR_INVALIDDATA;
     h     = 1 << log2h;
     code  = get_vlc2(&f->gb, block_type_vlc[1 - (f->version > 1)][index].table,
                      BLOCK_TYPE_VLC_BITS, 1);