[FIX] NUL-terminate mode/info strings in add_cc_sub_text - #2331
Conversation
strncpy of length 4 left 4-character strings such as ISDB and BURN without a terminator. Co-authored-by: Cursor <cursoragent@cursor.com>
The format_rust CI job treats clippy warnings as errors. Initialize c_len in one expression so the check passes. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Greetings maintainers |
CCExtractor CI platform finished running the test files on windows. 167/237 tests matched the approved output:
70 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.
Compared with the tip of master — test 9495, commit 3af3fc2:
Pass there, fail here:
Compared with the commit this branch was cut from: the same run as the tip of master (test 9495), so the comparison above already covers it. This branch changes the behaviour of 1 test(s) relative to the tip of master. Those are the ones worth looking at; anything else in the list fails the same way on both sides. |
cfsmp3
left a comment
There was a problem hiding this comment.
@NaitikVerma6776 The C bit looks good, but the Rust part is unrelated. Can just remove it and leave the C issue fix only?
This reverts commit fc7ab97.
|
hey @cfsmp3 .... removed the Rust/clippy change. The PR is only the C fix in |
CCExtractor CI platform finished running the test files on linux. 167/237 tests matched the approved output:
70 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.
Compared with the tip of master — test 9499, commit 3af3fc2:
Compared with the commit this branch was cut from: the same run as the tip of master (test 9499), so the comparison above already covers it. No test changes behaviour relative to the tip of master: every failure above fails there too, byte for byte. The approved output for those tests is out of date, which is a baseline to review rather than a regression in this branch. |
Fixes #2330
In raising this pull request, I confirm the following (please check boxes):
Reason for this PR:
Sanity check:
Repro instructions:
This is a C string bug in
add_cc_sub_text(), not a single-file caption extraction failure. No video sample is attached because the defect is in howmode/infoare copied.struct cc_subtitlehaschar mode[5]andchar info[4]."ISDB"(ccx_decoders_isdb.c) and"BURN"(hardsubx_decoder.c).strncpy(..., 4). When the source is exactly 4 characters,strncpydoes not write'\0'.strcmp(sub->mode, "TLT")and"%s"onsub->mode(ccx_encoders_transcript.c), which requires a terminator."TLT"(3 characters) was already terminated bystrncpy. The first subtitle can also look fine if the struct wascalloc'd (the extra byte is already 0). Later nodes usemallocand can leavemode[4]as garbage.How to confirm from source: search for
add_cc_sub_text(..., "ISDB"/"BURN"and the oldstrncpy(..., 4)on master vs this branch.Summary
add_cc_sub_text()now copiesinfoandmodewithsizeof(field) - 1and always writes a terminating'\0'.That keeps 4-character labels such as
ISDBandBURNvalid C strings, so laterstrcmp/"%s"in transcript output cannot read past the array.No changelog update: this is a bug fix only. No new feature code.