aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-10-23 19:41:27 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2020-07-01 12:49:26 +0200
commite67955dcc65a1f3945eb246bb7abbe4a9dc192b4 (patch)
treeb2330d2c5e7d6f547a4624d27aa5527753574024
parent61cee1d67fcb41b122be04e88ee62e00fcaac804 (diff)
downloadffmpeg-e67955dcc65a1f3945eb246bb7abbe4a9dc192b4.tar.gz
avcodec/cook: Check samples_per_channel earlier
Fixes: division by zero Fixes: 18362/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_COOK_fuzzer-5653727679086592 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 57750bb629a145326e20b8760f21f1041464a937) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/cook.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index 794a47582d..fe73e82592 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -1225,6 +1225,15 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
return AVERROR_PATCHWELCOME;
}
}
+
+ /* Try to catch some obviously faulty streams, otherwise it might be exploitable */
+ if (q->samples_per_channel != 256 && q->samples_per_channel != 512 &&
+ q->samples_per_channel != 1024) {
+ avpriv_request_sample(avctx, "samples_per_channel = %d",
+ q->samples_per_channel);
+ return AVERROR_PATCHWELCOME;
+ }
+
/* Generate tables */
init_pow2table();
init_gain_table(q);
@@ -1260,14 +1269,6 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
q->saturate_output = saturate_output_float;
}
- /* Try to catch some obviously faulty streams, otherwise it might be exploitable */
- if (q->samples_per_channel != 256 && q->samples_per_channel != 512 &&
- q->samples_per_channel != 1024) {
- avpriv_request_sample(avctx, "samples_per_channel = %d",
- q->samples_per_channel);
- return AVERROR_PATCHWELCOME;
- }
-
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
if (channel_mask)
avctx->channel_layout = channel_mask;