From: Michael Niedermayer Date: Sun, 14 Jul 2019 22:35:49 +0000 (+0200) Subject: avcodec/ffwavesynth: Check if there is enough extradata before allocation X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=65bac4a7825e1f2bbf4112569ffa363cc1fdbce5;p=ffmpeg avcodec/ffwavesynth: Check if there is enough extradata before allocation Fixes: OOM Fixes: 15750/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFWAVESYNTH_fuzzer-5702090367696896 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Nicolas George Signed-off-by: Michael Niedermayer --- diff --git a/libavcodec/ffwavesynth.c b/libavcodec/ffwavesynth.c index 94a843e3cab..b319b3341a6 100644 --- a/libavcodec/ffwavesynth.c +++ b/libavcodec/ffwavesynth.c @@ -247,7 +247,7 @@ static int wavesynth_parse_extradata(AVCodecContext *avc) edata_end = edata + avc->extradata_size; ws->nb_inter = AV_RL32(edata); edata += 4; - if (ws->nb_inter < 0) + if (ws->nb_inter < 0 || (edata_end - edata) / 24 < ws->nb_inter) return AVERROR(EINVAL); ws->inter = av_calloc(ws->nb_inter, sizeof(*ws->inter)); if (!ws->inter)