From patchwork Thu Jan 5 22:31:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 2070 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp5566361vsb; Thu, 5 Jan 2017 14:31:41 -0800 (PST) X-Received: by 10.28.27.208 with SMTP id b199mr115849wmb.82.1483655501685; Thu, 05 Jan 2017 14:31:41 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g23si421674wme.37.2017.01.05.14.31.40; Thu, 05 Jan 2017 14:31:41 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 457BF689E9D; Fri, 6 Jan 2017 00:31:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4614868091A for ; Fri, 6 Jan 2017 00:31:27 +0200 (EET) Received: by mail-wm0-f67.google.com with SMTP id u144so849491wmu.0 for ; Thu, 05 Jan 2017 14:31:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=4QCJFQ/0N9IyWDNJgwc+OnIgalykApB/RbKKEWgp0wA=; b=rSQJqvyt4avQjbxe4GoGbWa4eMb1FDixuKZWOcHrAn4U12qvvMBHU5PL7wobS/hh5F 44xa2W7b6GAfVhInv8Hg72SzhR/ob22MgEqqWQO23fd37zYjMzjWHbQWF+TO7r5oySIW a+lzQ5iBkw1WusLuHFMJA8IDGxkqjWlZwknIG1kITeB+fcZeIq+B7zI5yWDEe1SGn5Oy 9m33rtowCtCfe7HrH1JVTmcuWDsxPIIOYeW3U3lQdP7JcBz6li2IYsbx5gDcdiKB1O3r zVTUVlQ0cGDQRSUy+nOAVxPpVGkxhGK8RGaXYs8nxAOtkRXCz9EFFhqXQAVcuR4bWNTz UukQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=4QCJFQ/0N9IyWDNJgwc+OnIgalykApB/RbKKEWgp0wA=; b=SCcrWhLYGocHvguceEp/DO0uRyyj76eXoU2V26ERdydY8VBqvg5OZDqNyPXvmNPKUu faMkWQHHoAl0F5ZMrRkI8z3+0euN4+yTwjasabeJS1hNFgK4XhWE85aHgDaPtfGfj4q4 OfSe252mSwjhZtYT3JY7gd1o62EinpUnpmPcvoZuOJxyqvT8RD4zWNwPK3PD51mvONFx 1U4xj3vuOL9iv5MmQ2jD/LfR9LT3y9z/PLME1D4HrGFBPhp8K97p+Lb6phbL6MgZxq1e sPbBsQH1dez2JlJiecuZ9wNhmmR4CYXIpuF/umwlUV/VbG0NxWKIs+BGgWRNUFyYuRRx IqXA== X-Gm-Message-State: AIkVDXKeOsjf/lAKSc0X7sf+RC7mH/plnwbEMUM41Bx4n0WR+2bKm1+Kgq6pK3pFHmIaNa85JwID6agpXer/Zw== X-Received: by 10.28.65.194 with SMTP id o185mr112233wma.104.1483655492283; Thu, 05 Jan 2017 14:31:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.171.106 with HTTP; Thu, 5 Jan 2017 14:31:31 -0800 (PST) In-Reply-To: <20170105175306.GD4749@nb4> References: <20170105002856.14251-1-lq@chinaffmpeg.org> <20170105175306.GD4749@nb4> From: Steven Liu Date: Fri, 6 Jan 2017 06:31:31 +0800 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix Explicit null dereferenced in hlsenc X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 2017-01-06 1:53 GMT+08:00 Michael Niedermayer : > 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 > > --- > > 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 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 Signed-off-by: Steven Liu --- libavformat/hlsenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) if (!sub_path) { ret = AVERROR(ENOMEM); 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);