]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/adpcm: Check block align for AV_CODEC_ID_ADPCM_PSX
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 29 Sep 2020 19:23:39 +0000 (21:23 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 11 Oct 2020 14:42:49 +0000 (16:42 +0200)
Regression since: ca49476ace90ddebc5f92d9d82297f77e528c21e
Fixes: out of array write
Fixes: 25786/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_PSX_fuzzer-5704869380620288
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/adpcm.c

index 4755308824a6c6f0b160ab34c3d3438aaa4242f5..37d503ff6c7c5fdc7344173f7574ce0fec942938 100644 (file)
@@ -135,6 +135,8 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
         break;
     case AV_CODEC_ID_ADPCM_PSX:
         max_channels = 8;
+        if (avctx->block_align % (16 * avctx->channels))
+            return AVERROR_INVALIDDATA;
         break;
     case AV_CODEC_ID_ADPCM_IMA_DAT4:
     case AV_CODEC_ID_ADPCM_THP:
@@ -1968,6 +1970,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
             int nb_samples_per_block = 28 * FFMAX(avctx->block_align, 16 * avctx->channels) / (16 * avctx->channels);
             for (channel = 0; channel < avctx->channels; channel++) {
                 samples = samples_p[channel] + block * nb_samples_per_block;
+                av_assert0((block + 1) * nb_samples_per_block <= nb_samples);
 
                 /* Read in every sample for this channel.  */
                 for (i = 0; i < nb_samples_per_block / 28; i++) {