[FFmpeg-cvslog] avcodec/wmalosslessdec: move channel check up
Michael Niedermayer
git at videolan.org
Fri Apr 24 02:13:04 EEST 2020
ffmpeg | branch: release/2.8 | Michael Niedermayer <michael at niedermayer.cc> | Wed Jan 15 00:32:55 2020 +0100| [ff7e2172d3dc5bb2e0ba2c75ff41a1390cc05e90] | committer: Michael Niedermayer
avcodec/wmalosslessdec: move channel check up
Fixes: out of array access
Fixes: 2nd part of 18429/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMALOSSLESS_fuzzer-6210814364614656
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 891bcc4acc93e0c5a75ab7a9da668df84a0edba7)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ff7e2172d3dc5bb2e0ba2c75ff41a1390cc05e90
---
libavcodec/wmalosslessdec.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c
index 8fb08fb36d..e7c8266cf2 100644
--- a/libavcodec/wmalosslessdec.c
+++ b/libavcodec/wmalosslessdec.c
@@ -190,6 +190,16 @@ static av_cold int decode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
+ if (avctx->channels < 0) {
+ av_log(avctx, AV_LOG_ERROR, "invalid number of channels %d\n",
+ avctx->channels);
+ return AVERROR_INVALIDDATA;
+ } else if (avctx->channels > WMALL_MAX_CHANNELS) {
+ avpriv_request_sample(avctx,
+ "More than %d channels", WMALL_MAX_CHANNELS);
+ return AVERROR_PATCHWELCOME;
+ }
+
s->avctx = avctx;
ff_llauddsp_init(&s->dsp);
init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE);
@@ -263,16 +273,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
++s->lfe_channel;
}
- if (s->num_channels < 0) {
- av_log(avctx, AV_LOG_ERROR, "invalid number of channels %"PRId8"\n",
- s->num_channels);
- return AVERROR_INVALIDDATA;
- } else if (s->num_channels > WMALL_MAX_CHANNELS) {
- avpriv_request_sample(avctx,
- "More than %d channels", WMALL_MAX_CHANNELS);
- return AVERROR_PATCHWELCOME;
- }
-
s->frame = av_frame_alloc();
if (!s->frame)
return AVERROR(ENOMEM);
More information about the ffmpeg-cvslog
mailing list