From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 6A3AA454DD for ; Sat, 1 Apr 2023 21:34:20 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 665E3689CE2; Sun, 2 Apr 2023 00:34:19 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D9319689CE2 for ; Sun, 2 Apr 2023 00:34:11 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A0EC7E8976 for ; Sat, 1 Apr 2023 23:33:57 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UnOu3TqdNoCP for ; Sat, 1 Apr 2023 23:33:53 +0200 (CEST) Received: from iq (iq [217.27.212.140]) by iq.passwd.hu (Postfix) with ESMTPS id DB9B6E890F for ; Sat, 1 Apr 2023 23:33:52 +0200 (CEST) Date: Sat, 1 Apr 2023 23:33:52 +0200 (CEST) From: Marton Balint To: FFmpeg development discussions and patches In-Reply-To: <20230328221053.26905-1-cus@passwd.hu> Message-ID: <143fab49-726c-f76a-247f-29ed3e67ef8b@passwd.hu> References: <20230328221053.26905-1-cus@passwd.hu> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] avformat/assenc: avoid incorrect copy of null terminator 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Wed, 29 Mar 2023, Marton Balint wrote: > When writing a subtitle SSA/ASS subtitle file, the AVCodecParameters::extradata > buffer is written directly to the output. In the case where the buffer is > filled from a matroska source file produced by some older versions of > Handbrake, this buffer ends with a null terminating character, which is then > erroneously copied into the middle of the output file. The change here avoids > this problem by treating it as a string rather than a raw buffer. This way it > is agnostic as to whether the source buffer was null terminated or not. > > Fixes ticket #10203. Will apply. Regards, Marton > > Reported-by: Tim Angus > Signed-off-by: Marton Balint > --- > libavformat/assenc.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/libavformat/assenc.c b/libavformat/assenc.c > index 85a1e53371..6ecfb04517 100644 > --- a/libavformat/assenc.c > +++ b/libavformat/assenc.c > @@ -70,8 +70,9 @@ static int write_header(AVFormatContext *s) > ass->trailer = trailer; > } > > + header_size = av_strnlen(par->extradata, header_size); > avio_write(s->pb, par->extradata, header_size); > - if (par->extradata[header_size - 1] != '\n') > + if (header_size && par->extradata[header_size - 1] != '\n') > avio_write(s->pb, "\r\n", 2); > ass->ssa_mode = !strstr(par->extradata, "\n[V4+ Styles]"); > if (!strstr(par->extradata, "\n[Events]")) > -- > 2.35.3 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".