Skip to content

[FIX] Reject malformed credits time options instead of aborting - #2386

Merged
cfsmp3 merged 2 commits into
CCExtractor:masterfrom
kaihere14:fix-time-option-unwrap
Oct 18, 2026
Merged

cfsmp3 merged 2 commits into
CCExtractor:masterfrom
kaihere14:fix-time-option-unwrap

Conversation

@kaihere14

@kaihere14 kaihere14 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The six start/end credits timing options (--startcreditsnotbefore, --startcreditsnotafter, --startcreditsforatleast, --startcreditsforatmost, --endcreditsforatleast, --endcreditsforatmost) called stringztoms(...).unwrap(). A bad value panicked inside ccxr_parse_parameters, which is extern "C", so the panic could not unwind and the process aborted (exit 134, SIGABRT) with no explanation.

#2374 fixed this for --startat and --endat by validating the value in clap. This PR does the same for the credits options, so all eight time options behave the same way.

Fix

The six Args fields become Option<Timestamp> with value_parser=Timestamp::parse_optional_hhmmss_from_str, like startat/endat. parse_parameters then copies the parsed value, with no unwrap().

$ ccextractor --startcreditsforatmost abc input.scc
error: invalid value 'abc' for '--startcreditsforatmost <time>': error occurred during parsing

Testing

  • test_credits_time_rejects_invalid_values: all six options reject "", invalid, 60, 00:60, 1::2 and 1:2:3:4 as clap value-validation errors naming the option.
  • test_credits_time_formats: all six accept S, MM:SS and HH:MM:SS and set the right enc_cfg fields.
  • Full cargo test: 418 passed. cargo fmt --check is clean.
  • Built with mac/build.command and ran each option with abc (clap error, no panic). A valid --startcreditsforatmost 2 --endcreditsforatmost 3 still exits 0.

--startat, --endat and the start/end credits timing options called
stringztoms(...).unwrap(), so a value such as "abc" panicked inside
ccxr_parse_parameters. A panic cannot unwind through the extern "C"
boundary, so the process aborted with SIGABRT (exit 134) and no
explanation. Report the value with ExitCause::MalformedParameter like
the other malformed parameters do.
CCExtractor#2374 already validates --startat and --endat in clap. Do the same for
the six start/end credits timing options and drop the helper this
branch added.
@kaihere14 kaihere14 changed the title [FIX] Report malformed time options instead of aborting [FIX] Reject malformed credits time options instead of aborting Oct 18, 2026
@ccextractor-bot

Copy link
Copy Markdown
Collaborator
CCExtractor CI platform finished running the test files on linux. 106/237 tests matched the approved output:
Report Name Tests Passed
Broken 0/13
CEA-708 2/14
DVB 0/7
DVD 3/3
DVR-MS 0/2
General 0/27
Hardsubx 1/1
Hauppage 0/3
MP4 0/3
NoCC 10/10
Options 69/86
Teletext 0/21
WTV 0/13
XDS 21/34

131 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 9672, commit 429de8b:

  • 0 pass there and fail here
  • 95 fail there and pass here
  • 13 fail on both, with different output
  • 118 fail on both, byte for byte the same

Fail on both but produce different output — behaviour moved even though the verdict did not:

  • ccextractor --autoprogram --out=srt --latin1 --ucla d037c7509e...
  • ccextractor --out=spupng c83f765c66...
  • ccextractor --dru c83f765c66...
  • ccextractor --startat 4 --endat 7 c83f765c66...
  • ccextractor --codec dvbsub --out=spupng 85271be4d2...
  • ccextractor --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9...
  • ccextractor --startcreditsnotbefore 1 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9...
  • ccextractor --startcreditsnotafter 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9...
  • ccextractor --startcreditsforatleast 1 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9...
  • ccextractor --startcreditsforatmost 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9...
  • ccextractor --tpage 801 4e56e88ba4...
  • ccextractor --tverbose 4e56e88ba4...
  • ccextractor --teletext 4e56e88ba4...

Fail there, pass here:


Compared with the commit this branch was cut from — test 9678, commit 13d3372:

  • 0 pass there and fail here
  • 95 fail there and pass here
  • 13 fail on both, with different output
  • 118 fail on both, byte for byte the same

Fail on both but produce different output — behaviour moved even though the verdict did not:

  • ccextractor --autoprogram --out=srt --latin1 --ucla d037c7509e...
  • ccextractor --out=spupng c83f765c66...
  • ccextractor --dru c83f765c66...
  • ccextractor --startat 4 --endat 7 c83f765c66...
  • ccextractor --codec dvbsub --out=spupng 85271be4d2...
  • ccextractor --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9...
  • ccextractor --startcreditsnotbefore 1 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9...
  • ccextractor --startcreditsnotafter 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9...
  • ccextractor --startcreditsforatleast 1 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9...
  • ccextractor --startcreditsforatmost 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9...
  • ccextractor --tpage 801 4e56e88ba4...
  • ccextractor --tverbose 4e56e88ba4...
  • ccextractor --teletext 4e56e88ba4...

Fail there, pass here:


This branch changes the behaviour of 13 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
cfsmp3 merged commit bee7481 into CCExtractor:master Oct 18, 2026
26 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants