From de15b282136c33399f1f5b30793a0510151ed765 Mon Sep 17 00:00:00 2001 From: gnattu Date: Tue, 26 Nov 2024 13:37:49 +0800 Subject: [PATCH] avformat/assenc: do not copy null terminator The `par->extradata` buffer filled from some matroska files may be null terminated, and use `ffio_write_lines` using the full buffer length will copy this null character into the output files. This results in a file in which there is a null terminator after the header, but preceeding the actual content of the subtitle file. Treat this buffer as a string and write line with the text length of this buffer to skip the null character. Regression from 7bf1b9b --- .../patches/0082-fix-ass-incorrect-null-copy.patch | 14 ++++++++++++++ debian/patches/series | 1 + 2 files changed, 15 insertions(+) create mode 100644 debian/patches/0082-fix-ass-incorrect-null-copy.patch diff --git a/debian/patches/0082-fix-ass-incorrect-null-copy.patch b/debian/patches/0082-fix-ass-incorrect-null-copy.patch new file mode 100644 index 000000000..8268f816a --- /dev/null +++ b/debian/patches/0082-fix-ass-incorrect-null-copy.patch @@ -0,0 +1,14 @@ +Index: FFmpeg/libavformat/assenc.c +=================================================================== +--- FFmpeg.orig/libavformat/assenc.c ++++ FFmpeg/libavformat/assenc.c +@@ -67,7 +67,8 @@ static int write_header(AVFormatContext + ass->trailer = trailer; + } + +- ffio_write_lines(s->pb, par->extradata, header_size, NULL); ++ header_size = av_strnlen(par->extradata, header_size); ++ ffio_write_lines(s->pb, par->extradata, (int)header_size, NULL); + + ass->ssa_mode = !strstr(par->extradata, "\n[V4+ Styles]"); + if (!strstr(par->extradata, "\n[Events]")) diff --git a/debian/patches/series b/debian/patches/series index eaf930b42..703cd1370 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -79,3 +79,4 @@ 0079-videotoolbox-remove-opengl-compatability.patch 0080-use-dynamic-pool-for-vpl-qsv-hwupload.patch 0081-backport-av1-videotoolbox.patch +0082-fix-ass-incorrect-null-copy.patch