diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2019-06-17 20:58:47 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2019-11-11 20:18:46 +0100 |
commit | 25710f9563615d0f423e6e807c6e82f0ddce556a (patch) | |
tree | 99ec4e6a1c95a673b6f54710d28296a486c4d774 | |
parent | f2b03beef0e10e3139bf1cbb14beec58eebe2f4d (diff) | |
download | ffmpeg-25710f9563615d0f423e6e807c6e82f0ddce556a.tar.gz |
avcodec/qdm2: Move fft_order check up
This avoids undefined computations with unchecked values
Fixes: shift exponent -21 is negative
Fixes: 15262/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QDM2_fuzzer-5651261753393152
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 8d8b8c4ac6fb5b5d40bd131f2d2ea9d85b8759a6)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/qdm2.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index 88b6b19d11..1397218bdd 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -1702,6 +1702,12 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx) s->fft_order = av_log2(s->fft_size) + 1; + // Fail on unknown fft order + if ((s->fft_order < 7) || (s->fft_order > 9)) { + avpriv_request_sample(avctx, "Unknown FFT order %d", s->fft_order); + return AVERROR_PATCHWELCOME; + } + // something like max decodable tones s->group_order = av_log2(s->group_size) + 1; s->frame_size = s->group_size / 16; // 16 iterations per super block @@ -1735,11 +1741,6 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx) else s->coeff_per_sb_select = 2; - // Fail on unknown fft order - if ((s->fft_order < 7) || (s->fft_order > 9)) { - avpriv_request_sample(avctx, "Unknown FFT order %d", s->fft_order); - return AVERROR_PATCHWELCOME; - } if (s->fft_size != (1 << (s->fft_order - 1))) { av_log(avctx, AV_LOG_ERROR, "FFT size %d not power of 2.\n", s->fft_size); return AVERROR_INVALIDDATA; |