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

Submitted by Michael Niedermayer on Oct. 9, 2019, 10:14 a.m.

Details

Message ID 20191009101454.1608-2-michael@niedermayer.cc
State Accepted
Commit 5de19160a3c0dedb3cefd00e863a8d8f74ca2ad0
Headers show

Commit Message

Michael Niedermayer Oct. 9, 2019, 10:14 a.m.
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
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/pcm.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Paul B Mahol Oct. 9, 2019, 10:28 a.m.
lgtm

On 10/9/19, Michael Niedermayer <michael@niedermayer.cc> wrote:
> 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
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/pcm.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
> index 83850cc793..4ce0b9487b 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 ||
> 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)
> --
> 2.23.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer Oct. 10, 2019, 11:56 a.m.
On Wed, Oct 09, 2019 at 12:28:28PM +0200, Paul B Mahol wrote:
> lgtm

will apply

thx

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 83850cc793..4ce0b9487b 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 || 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)