From patchwork Tue Jan 31 11:13:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Angus X-Patchwork-Id: 40190 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3ca3:b0:b9:1511:ac2c with SMTP id b35csp4142954pzj; Tue, 31 Jan 2023 03:14:27 -0800 (PST) X-Google-Smtp-Source: AK7set/tLckDLSb8OPfYNRZTJ2ItQ/2ITh9pBxeUTyUQh9v9I8BmLD40euVyj+4a4TypftBuqu/e X-Received: by 2002:a05:6402:ea7:b0:4a2:5d67:9e98 with SMTP id h39-20020a0564020ea700b004a25d679e98mr3308805eda.4.1675163667657; Tue, 31 Jan 2023 03:14:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675163667; cv=none; d=google.com; s=arc-20160816; b=ZYBkB5VSOphO9iqANiNMvaMmzhVFZ0j276uScPKWGzqF0lOrkHiiEU8mVpiKTsofTh iedX1G0nTh8OAJg358f9VKwIYOo23aJxmChw/Bru1tBo1drugJUzBfymVA4WiCsjeMDD TgAWbsq1kov0qU+X/GCuk7Oi91mV96FH70HBZWmAnflWKRseIcZPf0WWdob0hcKDVi/1 j06g1PaAgID8lu5npLnZkBLxZ6cwF1WAGrjD+U3YMdUiCRG7+dU2q4d3kbAbTpE5Ky/c DfL5xLS12uvnyCypYPj2AWUWSHMKeZS26dNl3X7DpUjMjzfIfXTIgdvqldqnflugrT7W voxg== 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:mime-version:message-id:date:to:from :delivered-to; bh=kVJT1lk4ZPFrxjGSjUF1XxFQ70c+jD/L5Wgqk+7S1is=; b=nlB2ur3pGs3nQQJV8qeerY3rGvWtlqLxh1SjdEvFueRSwB9N/m+gbMgy+s0DicGDFF ykNfzNI3B9sUXBcY99Pe1pa60NwrQbMpZmzCXinlfb6bGo/78GDDUH80Q4uP3FIqRSeN 9TF8yMAWOcIU3hsOHQzTcYuqPtdxDLflZPANaDlMhKyhVuMvCBA74NKqIB+tYJlCttvh u+DG8oQuqdnhNb22F4YfOrk8qvJzJDITQw88iGxcfpsL/DR1gZgEHW1mvxi3I9cp+5Jv mBTCilAi9ZXQNj699HkuNOB1HCEcV9SMDhbq/vudFXhlC3iRvsJyU9P7JbJ3DEJp7MIC CI4w== 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 ee27-20020a056402291b00b004a0b3d74a33si17164338edb.56.2023.01.31.03.14.15; Tue, 31 Jan 2023 03:14:27 -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 41F6568BE01; Tue, 31 Jan 2023 13:14:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mailrelay.ngus.net (mailrelay.ngus.net [109.237.26.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 708A368BC3B for ; Tue, 31 Jan 2023 13:14:04 +0200 (EET) Received: from cpc102338-sgyl38-2-0-cust655.18-2.cable.virginm.net ([77.102.34.144] helo=zebop) by mailrelay.ngus.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1pMoaQ-00CKMO-Po for ffmpeg-devel@ffmpeg.org; Tue, 31 Jan 2023 11:14:02 +0000 Received: from [192.168.101.3] (helo=localhost.localdomain) by zebop with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pMoaO-006uZe-5u; Tue, 31 Jan 2023 11:14:02 +0000 From: Tim Angus To: ffmpeg-devel@ffmpeg.org Date: Tue, 31 Jan 2023 11:13:49 +0000 Message-Id: <20230131111349.1338846-1-tim@ngus.net> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Score: -2.9 (--) Subject: [FFmpeg-devel] [PATCH 2/2] avformat/assenc: fix strstr calls on non-string 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: Tim Angus Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: JnVOxUle5CAR In the write_header function of the ASS encoder, extradata is searched for a substring using the strstr function. strstr expects a null terminated C string as its first parameter, but extradata is (notionally) not one of these, meaning that the calls to strstr only happen to work because (presumably) they encounter a 0 byte somewhere downstream of extradata. I say notionally because often extradata will in fact be null terminated (which causes other problems, see parent commit). Signed-off-by: Tim Angus --- libavformat/assenc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavformat/assenc.c b/libavformat/assenc.c index 4c9ea6f982..f6f5293bb7 100644 --- a/libavformat/assenc.c +++ b/libavformat/assenc.c @@ -83,12 +83,12 @@ static int write_header(AVFormatContext *s) if (header_string[strlen(header_string) - 1] != '\n') avio_printf(s->pb, "\r\n"); - av_free(header_string); - - ass->ssa_mode = !strstr(par->extradata, "\n[V4+ Styles]"); - if (!strstr(par->extradata, "\n[Events]")) + ass->ssa_mode = !strstr(header_string, "\n[V4+ Styles]"); + if (!strstr(header_string, "\n[Events]")) avio_printf(s->pb, "[Events]\r\nFormat: %s, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\r\n", ass->ssa_mode ? "Marked" : "Layer"); + + av_free(header_string); } return 0;