Skip to content

Commit

Permalink
avformat/assenc: do not copy null terminator
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gnattu committed Nov 26, 2024
1 parent 49d40b0 commit de15b28
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions debian/patches/0082-fix-ass-incorrect-null-copy.patch
Original file line number Diff line number Diff line change
@@ -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]"))
1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit de15b28

Please sign in to comment.