diff mbox

[FFmpeg-devel,04/12] avcodec/hcom: Check that there are dictionary entries

Message ID 20190925203858.27870-4-michael@niedermayer.cc
State Accepted
Commit b2785cd3ac05388b769bc68c083aa4770c632c3e
Headers show

Commit Message

Michael Niedermayer Sept. 25, 2019, 8:38 p.m. UTC
Fixes: out of array read
Fixes: 17617/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HCOM_fuzzer-5674970478280704

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

Comments

Paul B Mahol Sept. 26, 2019, 7:55 a.m. UTC | #1
lgtm

On 9/25/19, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: out of array read
> Fixes:
> 17617/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HCOM_fuzzer-5674970478280704
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/hcom.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/hcom.c b/libavcodec/hcom.c
> index bce9e80aa5..0559b050c3 100644
> --- a/libavcodec/hcom.c
> +++ b/libavcodec/hcom.c
> @@ -52,7 +52,8 @@ static av_cold int hcom_init(AVCodecContext *avctx)
>      if (avctx->extradata_size <= 7)
>          return AVERROR_INVALIDDATA;
>      s->dict_entries = AV_RB16(avctx->extradata);
> -    if (avctx->extradata_size < s->dict_entries * 4 + 7)
> +    if (avctx->extradata_size < s->dict_entries * 4 + 7 ||
> +        s->dict_entries == 0)
>          return AVERROR_INVALIDDATA;
>      s->delta_compression = AV_RB32(avctx->extradata + 2);
>      s->sample = s->first_sample = avctx->extradata[avctx->extradata_size -
> 1];
> --
> 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-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer Sept. 26, 2019, 6:33 p.m. UTC | #2
On Thu, Sep 26, 2019 at 09:55:12AM +0200, Paul B Mahol wrote:
> lgtm

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/hcom.c b/libavcodec/hcom.c
index bce9e80aa5..0559b050c3 100644
--- a/libavcodec/hcom.c
+++ b/libavcodec/hcom.c
@@ -52,7 +52,8 @@  static av_cold int hcom_init(AVCodecContext *avctx)
     if (avctx->extradata_size <= 7)
         return AVERROR_INVALIDDATA;
     s->dict_entries = AV_RB16(avctx->extradata);
-    if (avctx->extradata_size < s->dict_entries * 4 + 7)
+    if (avctx->extradata_size < s->dict_entries * 4 + 7 ||
+        s->dict_entries == 0)
         return AVERROR_INVALIDDATA;
     s->delta_compression = AV_RB32(avctx->extradata + 2);
     s->sample = s->first_sample = avctx->extradata[avctx->extradata_size - 1];