diff mbox

[FFmpeg-devel] avformat/hlsenc: fix Explicit null dereferenced in hlsenc

Message ID CADxeRwkmqf3RjBYHgj6JZYALbpmsy6Q7f01gN3-HAs4ovGuKNg@mail.gmail.com
State Accepted
Headers show

Commit Message

Steven Liu Jan. 5, 2017, 10:31 p.m. UTC
2017-01-06 1:53 GMT+08:00 Michael Niedermayer <michael@niedermayer.cc>:

> On Thu, Jan 05, 2017 at 08:28:56AM +0800, Steven Liu wrote:
> > CID: 1398228
> > Passing null pointer dirname to strlen, which dereferences it.
> >
> > Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > ---
> >  libavformat/hlsenc.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> > index 808a797..3c6490a 100644
> > --- a/libavformat/hlsenc.c
> > +++ b/libavformat/hlsenc.c
> > @@ -285,8 +285,8 @@ static int hls_delete_old_segments(HLSContext *hls)
> {
> >                                       path, strerror(errno));
> >          }
> >
> > -        if (segment->sub_filename[0] != '\0') {
> > -            sub_path_size = strlen(dirname) +
> strlen(segment->sub_filename) + 1;
> > +        if ((segment->sub_filename[0] != '\0')) {
>
> > +            sub_path_size = (!dirname) ? (strlen(segment->sub_filename)
> + 1) : (strlen(dirname) + strlen(segment->sub_filename) + 1);
>
> simpler:
> sub_path_size = strlen(segment->sub_filename) + 1 + (dirname ?
> strlen(dirname) : 0);


>
> [...]
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> There will always be a question for which you do not know the correct
> answer.
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> From 57ae94a3c0fced20464d9ae351efc977d964be38 Mon Sep 17 00:00:00 2001
From: Steven Liu <lq@chinaffmpeg.org>
Date: Fri, 6 Jan 2017 06:29:12 +0800
Subject: [PATCH] avformat/hlsenc: fix Explicit null dereferenced in hlsenc

CID: 1398228
Passing null pointer dirname to strlen, which dereferences it.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/hlsenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

             if (!sub_path) {
                 ret = AVERROR(ENOMEM);
diff mbox

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 920987f..eeb450a 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -285,8 +285,8 @@  static int hls_delete_old_segments(HLSContext *hls) {
                                      path, strerror(errno));
         }

-        if (segment->sub_filename[0] != '\0') {
-            sub_path_size = strlen(dirname) +
strlen(segment->sub_filename) + 1;
+        if ((segment->sub_filename[0] != '\0')) {
+            sub_path_size = strlen(segment->sub_filename) + 1 + (dirname ?
strlen(dirname) : 0);
             sub_path = av_malloc(sub_path_size);