diff mbox

[FFmpeg-devel,1/2] avcodec/assdec: undefined use of memcpy()

Message ID 20190724213538.29475-1-michael@niedermayer.cc
State Accepted
Commit 47b6ca0b022a413e392707464f2423795aa89bfb
Headers show

Commit Message

Michael Niedermayer July 24, 2019, 9:35 p.m. UTC
Fixes: null pointer passed as argument 2, which is declared to never be null
Fixes: 16008/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SSA_fuzzer-5650582821404672 (this is a separate issue found in this testcase)

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

Comments

Paul B Mahol July 25, 2019, 9:38 a.m. UTC | #1
On 7/24/19, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: null pointer passed as argument 2, which is declared to never be null
> Fixes:
> 16008/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SSA_fuzzer-5650582821404672
> (this is a separate issue found in this testcase)
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/assdec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/assdec.c b/libavcodec/assdec.c
> index 3178f2953c..f0b1069cd2 100644
> --- a/libavcodec/assdec.c
> +++ b/libavcodec/assdec.c
> @@ -31,7 +31,8 @@ static av_cold int ass_decode_init(AVCodecContext *avctx)
>      avctx->subtitle_header = av_malloc(avctx->extradata_size + 1);
>      if (!avctx->subtitle_header)
>          return AVERROR(ENOMEM);
> -    memcpy(avctx->subtitle_header, avctx->extradata,
> avctx->extradata_size);
> +    if (avctx->extradata_size)
> +        memcpy(avctx->subtitle_header, avctx->extradata,
> avctx->extradata_size);
>      avctx->subtitle_header[avctx->extradata_size] = 0;
>      avctx->subtitle_header_size = avctx->extradata_size;
>      return 0;
> --
> 2.22.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".

i guess it is fine
Michael Niedermayer July 26, 2019, 5:30 p.m. UTC | #2
On Thu, Jul 25, 2019 at 11:38:48AM +0200, Paul B Mahol wrote:
> On 7/24/19, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > Fixes: null pointer passed as argument 2, which is declared to never be null
> > Fixes:
> > 16008/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SSA_fuzzer-5650582821404672
> > (this is a separate issue found in this testcase)
> >
> > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/assdec.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/assdec.c b/libavcodec/assdec.c
> > index 3178f2953c..f0b1069cd2 100644
> > --- a/libavcodec/assdec.c
> > +++ b/libavcodec/assdec.c
> > @@ -31,7 +31,8 @@ static av_cold int ass_decode_init(AVCodecContext *avctx)
> >      avctx->subtitle_header = av_malloc(avctx->extradata_size + 1);
> >      if (!avctx->subtitle_header)
> >          return AVERROR(ENOMEM);
> > -    memcpy(avctx->subtitle_header, avctx->extradata,
> > avctx->extradata_size);
> > +    if (avctx->extradata_size)
> > +        memcpy(avctx->subtitle_header, avctx->extradata,
> > avctx->extradata_size);
> >      avctx->subtitle_header[avctx->extradata_size] = 0;
> >      avctx->subtitle_header_size = avctx->extradata_size;
> >      return 0;
> > --
> > 2.22.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".
> 
> i guess it is fine

will apply

Thank you!

[...]
diff mbox

Patch

diff --git a/libavcodec/assdec.c b/libavcodec/assdec.c
index 3178f2953c..f0b1069cd2 100644
--- a/libavcodec/assdec.c
+++ b/libavcodec/assdec.c
@@ -31,7 +31,8 @@  static av_cold int ass_decode_init(AVCodecContext *avctx)
     avctx->subtitle_header = av_malloc(avctx->extradata_size + 1);
     if (!avctx->subtitle_header)
         return AVERROR(ENOMEM);
-    memcpy(avctx->subtitle_header, avctx->extradata, avctx->extradata_size);
+    if (avctx->extradata_size)
+        memcpy(avctx->subtitle_header, avctx->extradata, avctx->extradata_size);
     avctx->subtitle_header[avctx->extradata_size] = 0;
     avctx->subtitle_header_size = avctx->extradata_size;
     return 0;