]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/pcm: Check bits_per_coded_sample
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 28 Sep 2019 23:22:37 +0000 (01:22 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 10 Oct 2019 12:34:20 +0000 (14:34 +0200)
Fixes: shift exponent -2 is negative
Fixes: 17736/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PCM_F16LE_fuzzer-5742815929171968
Fixes: 17998/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PCM_F24LE_fuzzer-5716980383875072
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/pcm.c

index 83850cc793cc6986572c0699058c070385e7c025..4ce0b9487bb38803dca330d3128de973968ae23a 100644 (file)
@@ -264,6 +264,9 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx)
         break;
     case AV_CODEC_ID_PCM_F16LE:
     case AV_CODEC_ID_PCM_F24LE:
+        if (avctx->bits_per_coded_sample < 1 || avctx->bits_per_coded_sample > 24)
+            return AVERROR_INVALIDDATA;
+
         s->scale = 1. / (1 << (avctx->bits_per_coded_sample - 1));
         s->fdsp = avpriv_float_dsp_alloc(0);
         if (!s->fdsp)