Skip to content

Commit 395f9b3

Browse files
DhanushVarma-2Dhanush Varma
andauthored
fix: MKV subtitle track .(null) extension for KATE and unknown codec IDs (#2250)
* fix: MKV subtitle track .(null) extension for KATE and unknown codec IDs The matroska_track_text_subtitle_id_extensions array had 7 entries for an 8-value enum, leaving MATROSKA_TRACK_SUBTITLE_CODEC_ID_KATE (index 7) out of bounds. On most platforms this read NULL, which then caused strlen(NULL) UB and snprintf to emit .(null) in the output filename. Two fixes: - Add "kate" at index 7 in the extensions array so KATE tracks produce correct .kate output filenames - Add a NULL guard in generate_filename_from_track() so any future unknown codec ID safely falls back to .bin instead of crashing or producing .(null) Fixes #972 * fix: MKV subtitle track .(null) extension for KATE and unknown codec IDs The matroska_track_text_subtitle_id_extensions array had 7 entries for an 8-value enum, leaving MATROSKA_TRACK_SUBTITLE_CODEC_ID_KATE (index 7) out of bounds. On most platforms this read NULL, which then caused strlen(NULL) UB and snprintf to emit .(null) in the output filename. Two fixes: - Add "kate" at index 7 in the extensions array so KATE tracks produce correct .kate output filenames - Add a NULL guard in generate_filename_from_track() so any future unknown codec ID safely falls back to .bin instead of crashing or producing .(null) Fixes #972 * fix: MKV subtitle track .(null) extension for KATE and unknown codec IDs The matroska_track_text_subtitle_id_extensions array had 7 entries for an 8-value enum, leaving MATROSKA_TRACK_SUBTITLE_CODEC_ID_KATE (index 7) out of bounds. On most platforms this read NULL, which then caused strlen(NULL) UB and snprintf to emit .(null) in the output filename. Two fixes: - Add "kate" at index 7 in the extensions array so KATE tracks produce correct .kate output filenames - Add a NULL guard in generate_filename_from_track() so any future unknown codec ID safely falls back to .bin instead of crashing or producing .(null) Fixes #972 --------- Co-authored-by: Dhanush Varma <your@email.com>
1 parent 65df24e commit 395f9b3

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/lib_ccx/matroska.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,8 @@ char *generate_filename_from_track(struct matroska_ctx *mkv_ctx, struct matroska
13331333
{
13341334
const char *basename = get_basename(mkv_ctx->filename);
13351335
const char *extension = matroska_track_text_subtitle_id_extensions[track->codec_id];
1336+
if (extension == NULL)
1337+
extension = "bin";
13361338
/* Prefer the BCP-47 IETF tag (e.g. "zh-Hant") over the legacy
13371339
* ISO-639-2 code (e.g. "chi") when one is available. */
13381340
const char *lang_tag = track->lang_ietf ? track->lang_ietf : track->lang;

src/lib_ccx/matroska.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ char *matroska_track_text_subtitle_id_strings[] = {
179179
char *matroska_track_text_subtitle_id_extensions[] = {
180180
"srt", "ssa", "ass",
181181
"usf", "vtt", "bmp",
182-
"idx", NULL // Unknown
182+
"idx", "kate", NULL // Unknown/sentinel
183183
};
184184

185185
char *avc_codec_id = "V_MPEG4/ISO/AVC";

0 commit comments

Comments
 (0)