[FFmpeg-devel,5/5] avcodec/pcm: Check bits_per_coded_sample

Submitted by Michael Niedermayer on Sept. 28, 2019, 11:53 p.m.

Details

Message ID 20190928235345.26528-5-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Sept. 28, 2019, 11:53 p.m.
Fixes: shift exponent -2 is negative
Fixes: 17736/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PCM_F16LE_fuzzer-5742815929171968

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/pcm.c | 3 +++
 1 file changed, 3 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 83850cc793..abd61e281c 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -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)
+            return AVERROR_INVALIDDATA;
+
         s->scale = 1. / (1 << (avctx->bits_per_coded_sample - 1));
         s->fdsp = avpriv_float_dsp_alloc(0);
         if (!s->fdsp)