From patchwork Wed Dec 1 08:37:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 31859 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp8907035iob; Wed, 1 Dec 2021 00:38:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyo8DeUh6AkRFbaemB5jaMS2TmDwcVis7wTcMzrzaiC6fIZrQvYPHnD0TcoTd3VkRYvOTnw X-Received: by 2002:a17:907:160c:: with SMTP id hb12mr5428728ejc.460.1638347893817; Wed, 01 Dec 2021 00:38:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638347893; cv=none; d=google.com; s=arc-20160816; b=bGzNAWME/t35d9ZNg7Sk49xH/drzH39ODxfwUrqetJXrAQm35kxFpitw5umhPAq+yf lseV8SEGAHih9CC5JwQVuZaIOzEwKrJ9qI+mTVCLBJlexgdK8l3M5+UUsM/UDOXQ1m4v kb2N4ajTQ0Qzx1oUfV9maKjyFXaS0R2RFQtIsLyYK3dTg6dPLx5vcT1MZBsLdOkQm2uw 3I5QplgTK0ksKJzHSEARKHssdjPSpaWcFrRBi5rbPJqJdQBD9l5ogixde53OX7oeT0+F JAhpHxa4VvaJQHK/kD7NbPhD5RYJKID4NOrzEyrijou3+taC3mTKL+1wSMJIo+UNYNde utCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:mime-version:message-id:date :to:from:delivered-to; bh=DKPIH7vZygcftnExTBOk4uK8OAfzW8dz9+ySNyRLfYs=; b=WZPV5TRERDNyrf5iKR5g4VUW3ZDu2/ZH6uhcAYdeB54V3nREAO+nz8WL/FRh1rLFAL VCh83JcrLYOybif9bSSG2SogEj9m8pz+r1YmPisOhEnTpbMQPMfpdvSuY4YN17S7ee7y u+0sajzdsXJw7MherLiDDQXnfzZ8c2S24tey6skYxT2hIqk6hhj/XVZ5DYNF+AmseTxd 7Z6oiSWfKpwodYLtkSJ9xI1GyYLQKC7IfMlX8kCT+ATPSu+sjieED0XKqUDlqo32M8B+ tC7azAH/Om4QuF5VN/Ve37ZauP+WKjAXvnxJI27tQHxn4s1t7/ceqbnpHuthhV9ijxsw ynlg== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k3si31365994edk.215.2021.12.01.00.38.12; Wed, 01 Dec 2021 00:38:13 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A803268AE9B; Wed, 1 Dec 2021 10:38:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbg587.qq.com (smtpbg128.qq.com [106.55.201.39]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 74B07680831 for ; Wed, 1 Dec 2021 10:38:00 +0200 (EET) X-QQ-mid: bizesmtp53t1638347875txj6bsgo Received: from localhost (unknown [103.107.216.231]) by esmtp6.qq.com (ESMTP) with id ; Wed, 01 Dec 2021 16:37:54 +0800 (CST) X-QQ-SSF: 01100000002000Z0Z000B00A0000000 X-QQ-FEAT: j375Cqr75ui8GuJK2IsJe902lYEbwUtRpXhOuH7VqQYjopmSYJHV+5fCQpEH1 t8U8cuUOv3ZBMA/PCsFN7KlM3bjq6BYwvCPCl6AGa2DgcQipc7EZneJj27yZUfLR4ugVBuK WBg2DkX/wr0bjeV+1EWYVG5KaoGwLoIQB1FKVdhQgFgVBOA6ToM18lPaJ54aWBYbWcFQaTi C5Itr0u8zFLmbHcNjVtVESi3TTUrNpfxp/y9+CjTMs1Ip3L2MN/BGuyID/4RjGx/7B2nogu ha4wBiMNSC+Lx52+8i12FbJ6Tt8eRs1M5GhDgf9rgTvkoQpvEKrpVd3e+9tj4wIBwYPcDmP JLMM6Qoxa/jBCihJ5Q= X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Wed, 1 Dec 2021 16:37:52 +0800 Message-Id: <20211201083752.66991-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgspam:qybgspam5 Subject: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: fix SEGV in choose_pix_fmts after avio_close_dyn_buf X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: TOTE Robot , Steven Liu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: dYT0kpwIzDyX From: Steven Liu ret could be set to s->opaque->buffer in avio_close_dyn_buf, so it can be set to NULL, check NULL pointer deference after it should be ok. Reported-by: TOTE Robot Signed-off-by: Steven Liu --- fftools/ffmpeg_filter.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 452b689d62..f2f77ff86f 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -119,6 +119,8 @@ static char *choose_pix_fmts(OutputFilter *ofilter) avio_printf(s, "%s|", name); } len = avio_close_dyn_buf(s, &ret); + if (len <= 0 || !ret) + return NULL; ret[len - 1] = 0; return ret; } else