diff mbox series

[FFmpeg-devel,1/2] avcodec/adpcm: Clip step index for ADPCM_IMA_APM

Message ID 20200301225934.2350-1-michael@niedermayer.cc
State Accepted
Headers show
Series [FFmpeg-devel,1/2] avcodec/adpcm: Clip step index for ADPCM_IMA_APM
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Michael Niedermayer March 1, 2020, 10:59 p.m. UTC
Fixes: out of array access
Fixes: 20828/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_APM_fuzzer-5712770106654720

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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Paul B Mahol March 2, 2020, 8:40 a.m. UTC | #1
lgtm

On 3/1/20, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: out of array access
> Fixes:
> 20828/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_APM_fuzzer-5712770106654720
>
> 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 | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
> index b987e93c5f..5f152ee6ef 100644
> --- a/libavcodec/adpcm.c
> +++ b/libavcodec/adpcm.c
> @@ -154,9 +154,9 @@ static av_cold int adpcm_decode_init(AVCodecContext *
> avctx)
>      case AV_CODEC_ID_ADPCM_IMA_APM:
>          if (avctx->extradata && avctx->extradata_size >= 16) {
>              c->status[0].predictor  = AV_RL32(avctx->extradata +  0);
> -            c->status[0].step_index = AV_RL32(avctx->extradata +  4);
> +            c->status[0].step_index = av_clip(AV_RL32(avctx->extradata +
> 4), 0, 88);
>              c->status[1].predictor  = AV_RL32(avctx->extradata +  8);
> -            c->status[1].step_index = AV_RL32(avctx->extradata + 12);
> +            c->status[1].step_index = av_clip(AV_RL32(avctx->extradata +
> 12), 0, 88);
>          }
>          break;
>      case AV_CODEC_ID_ADPCM_IMA_WS:
> --
> 2.17.1
>
> _______________________________________________
> 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 March 2, 2020, 10:31 p.m. UTC | #2
On Mon, Mar 02, 2020 at 09:40:52AM +0100, Paul B Mahol wrote:
> lgtm

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index b987e93c5f..5f152ee6ef 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -154,9 +154,9 @@  static av_cold int adpcm_decode_init(AVCodecContext * avctx)
     case AV_CODEC_ID_ADPCM_IMA_APM:
         if (avctx->extradata && avctx->extradata_size >= 16) {
             c->status[0].predictor  = AV_RL32(avctx->extradata +  0);
-            c->status[0].step_index = AV_RL32(avctx->extradata +  4);
+            c->status[0].step_index = av_clip(AV_RL32(avctx->extradata +  4), 0, 88);
             c->status[1].predictor  = AV_RL32(avctx->extradata +  8);
-            c->status[1].step_index = AV_RL32(avctx->extradata + 12);
+            c->status[1].step_index = av_clip(AV_RL32(avctx->extradata + 12), 0, 88);
         }
         break;
     case AV_CODEC_ID_ADPCM_IMA_WS: