diff mbox

[FFmpeg-devel] avcodec/v210dec: move the stride read after its fully initialized

Message ID 20191201222647.21589-1-michael@niedermayer.cc
State Accepted
Commit ab3044368f3fc10a3d43718a2bd664be8ce9fdb5
Headers show

Commit Message

Michael Niedermayer Dec. 1, 2019, 10:26 p.m. UTC
Fixes: out of array read
Fixes: 19129/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_V210_fuzzer-5068171023482880
Maybe fixes: 19130/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_V210_fuzzer-5637264407527424

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

Comments

Lance Wang Dec. 11, 2019, 3:09 p.m. UTC | #1
On Sun, Dec 01, 2019 at 11:26:47PM +0100, Michael Niedermayer wrote:
> Fixes: out of array read
> Fixes: 19129/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_V210_fuzzer-5068171023482880
> Maybe fixes: 19130/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_V210_fuzzer-5637264407527424
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/v210dec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
> index 8483023815..044d35338b 100644
> --- a/libavcodec/v210dec.c
> +++ b/libavcodec/v210dec.c
> @@ -153,7 +153,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
>          int aligned_width = ((avctx->width + 47) / 48) * 48;
>          stride = aligned_width * 8 / 3;
>      }
> -    td.stride = stride;
>  
>      if (avpkt->size < stride * avctx->height) {
>          if ((((avctx->width + 23) / 24) * 24 * 8) / 3 * avctx->height == avpkt->size) {
> @@ -166,6 +165,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
>              return AVERROR_INVALIDDATA;
>          }
>      }
> +    td.stride = stride;

LGTM


>      if (   avctx->codec_tag == MKTAG('C', '2', '1', '0')
>          && avpkt->size > 64
>          && AV_RN32(psrc) == AV_RN32("INFO")
> -- 
> 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 Dec. 12, 2019, 5:46 p.m. UTC | #2
On Wed, Dec 11, 2019 at 11:09:12PM +0800, Limin Wang wrote:
> On Sun, Dec 01, 2019 at 11:26:47PM +0100, Michael Niedermayer wrote:
> > Fixes: out of array read
> > Fixes: 19129/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_V210_fuzzer-5068171023482880
> > Maybe fixes: 19130/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_V210_fuzzer-5637264407527424
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/v210dec.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
> > index 8483023815..044d35338b 100644
> > --- a/libavcodec/v210dec.c
> > +++ b/libavcodec/v210dec.c
> > @@ -153,7 +153,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
> >          int aligned_width = ((avctx->width + 47) / 48) * 48;
> >          stride = aligned_width * 8 / 3;
> >      }
> > -    td.stride = stride;
> >  
> >      if (avpkt->size < stride * avctx->height) {
> >          if ((((avctx->width + 23) / 24) * 24 * 8) / 3 * avctx->height == avpkt->size) {
> > @@ -166,6 +165,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
> >              return AVERROR_INVALIDDATA;
> >          }
> >      }
> > +    td.stride = stride;
> 
> LGTM

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index 8483023815..044d35338b 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -153,7 +153,6 @@  static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
         int aligned_width = ((avctx->width + 47) / 48) * 48;
         stride = aligned_width * 8 / 3;
     }
-    td.stride = stride;
 
     if (avpkt->size < stride * avctx->height) {
         if ((((avctx->width + 23) / 24) * 24 * 8) / 3 * avctx->height == avpkt->size) {
@@ -166,6 +165,7 @@  static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
             return AVERROR_INVALIDDATA;
         }
     }
+    td.stride = stride;
     if (   avctx->codec_tag == MKTAG('C', '2', '1', '0')
         && avpkt->size > 64
         && AV_RN32(psrc) == AV_RN32("INFO")