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

Michael Niedermayer michael at niedermayer.cc
Thu Jan 5 19:53:06 EET 2017


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 at 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170105/661171d3/attachment.sig>


More information about the ffmpeg-devel mailing list