Skip to content

fix(decoder): handle insufficient bytes in process_p16 and add unit test#2289

Open
Esha310 wants to merge 2 commits into
CCExtractor:masterfrom
Esha310:p16-byte-check
Open

fix(decoder): handle insufficient bytes in process_p16 and add unit test#2289
Esha310 wants to merge 2 commits into
CCExtractor:masterfrom
Esha310:p16-byte-check

Conversation

@Esha310

@Esha310 Esha310 commented Jul 1, 2026

Copy link
Copy Markdown

Updated the process_p16 method to check for sufficient data bytes before processing, logging a warning if the input is inadequate. Added a unit test to verify behavior when insufficient bytes are provided.

In raising this pull request, I confirm the following (please check boxes):

Reason for this PR:

  • This PR adds new functionality.
  • This PR fixes a bug that I have personally experienced or that a real user has reported and for which a sample exists.
  • This PR is porting code from C to Rust.

Sanity check:

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • If the PR adds new functionality, I've added it to the changelog. If it's just a bug fix, I have NOT added it to the changelog.
  • I am NOT adding new C code unless it's to fix an existing, reproducible bug.

Repro instructions:

The reproduction steps and the crashing MPEG-2 TS sample file are already provided by the original reporter in the linked issue.


Fixes #2278

This PR resolves the index out of bounds panic in service_decoder.rs that occurs when processing certain broadcast MPEG-2 files. Added a check to ensure sufficient data bytes exist in the block before processing p16, logging a warning instead of crashing. Also included a unit test to verify this behavior.

Esha310 added 2 commits July 1, 2026 11:49
Updated the `process_p16` method to check for sufficient data bytes before processing, logging a warning if the input is inadequate. Added a unit test to verify behavior when insufficient bytes are provided.
@ccextractor-bot

Copy link
Copy Markdown
Collaborator
CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit 2feb09a...:
Report Name Tests Passed
Broken 0/13
CEA-708 2/14
DVB 0/7
DVD 3/3
DVR-MS 0/2
General 8/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 72/86
Teletext 20/21
WTV 12/13
XDS 31/34

Your PR breaks these cases:

  • ccextractor --autoprogram --out=srt --latin1 1d9731bd80...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 8e8229b88b...
  • ccextractor --autoprogram --out=ttxt --latin1 7236304cfc...
  • ccextractor --out=srt --latin1 06b3a9237d...
  • ccextractor --out=srt --latin1 83f8cceb74...
  • ccextractor --out=srt --latin1 611b4a9235...
  • ccextractor --out=srt --latin1 b46e9e8e3f...
  • ccextractor --out=srt --latin1 89e417e622...
  • ccextractor --out=srt --latin1 d59eadc4ed...
  • ccextractor --out=sami --latin1 --autoprogram --no-goptime 5b4e0a6034...
  • ccextractor --autoprogram --out=ttxt --latin1 1020459a86...
  • ccextractor --datapid 5603 --autoprogram --out=srt --latin1 --teletext 85c7fc1ad7...
  • ccextractor --autoprogram --out=srt --latin1 --quant 0 85271be4d2...
  • ccextractor --wtvconvertfix --autoprogram --out=srt --latin1 acf871cbfd...
  • ccextractor --wtvconvertfix --autoprogram --out=srt --latin1 5cbb21adb6...
  • ccextractor --autoprogram --out=ttxt --latin1 99e5eaafdc...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 7aad20907e...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla c41f73056a...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 5d3a29f9f8...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 70000200c0...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 6dc772d881...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla dab1c1bd65...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla adce82fd39...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 15feae9133...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 95dd33c6f1...
  • ccextractor --autoprogram --out=ttxt --latin1 01509e4d27...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla ab9cf8cfad...
  • ccextractor --autoprogram --out=srt --latin1 15feae9133...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --output-field 2 5d3a29f9f8...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --output-field 2 c41f73056a...
  • ccextractor --autoprogram --out=srt --latin1 --sentencecap c032183ef0...
  • ccextractor --autoprogram --out=bin --latin1 c032183ef0...
  • ccextractor --out=srt --latin1 --autoprogram 29e5ffd34b...
  • 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 --out=srt --latin1 f23a544ba8...
  • ccextractor --autoprogram --out=srt --latin1 --ucla d037c7509e...
  • ccextractor --autoprogram --out=srt --latin1 --ucla 7d3f25c32c...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 7f41299cc7...

NOTE: The following tests have been failing on the master branch as well as the PR:

Congratulations: Merging this PR would fix the following tests:

  • ccextractor --service 1 --out=ttxt da904de35d..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 132d7df7e9..., Last passed: Never

It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you).

Check the result page for more info.

@Esha310

Esha310 commented Jul 1, 2026

Copy link
Copy Markdown
Author

CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit 2feb09a...:
Report Name Tests Passed
Broken 0/13
CEA-708 2/14
DVB 0/7
DVD 3/3
DVR-MS 0/2
General 8/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 72/86
Teletext 20/21
WTV 12/13
XDS 31/34
Your PR breaks these cases:

  • ccextractor --autoprogram --out=srt --latin1 1d9731bd80...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 8e8229b88b...
  • ccextractor --autoprogram --out=ttxt --latin1 7236304cfc...
  • ccextractor --out=srt --latin1 06b3a9237d...
  • ccextractor --out=srt --latin1 83f8cceb74...
  • ccextractor --out=srt --latin1 611b4a9235...
  • ccextractor --out=srt --latin1 b46e9e8e3f...
  • ccextractor --out=srt --latin1 89e417e622...
  • ccextractor --out=srt --latin1 d59eadc4ed...
  • ccextractor --out=sami --latin1 --autoprogram --no-goptime 5b4e0a6034...
  • ccextractor --autoprogram --out=ttxt --latin1 1020459a86...
  • ccextractor --datapid 5603 --autoprogram --out=srt --latin1 --teletext 85c7fc1ad7...
  • ccextractor --autoprogram --out=srt --latin1 --quant 0 85271be4d2...
  • ccextractor --wtvconvertfix --autoprogram --out=srt --latin1 acf871cbfd...
  • ccextractor --wtvconvertfix --autoprogram --out=srt --latin1 5cbb21adb6...
  • ccextractor --autoprogram --out=ttxt --latin1 99e5eaafdc...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 7aad20907e...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla c41f73056a...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 5d3a29f9f8...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 70000200c0...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 6dc772d881...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla dab1c1bd65...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla adce82fd39...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 15feae9133...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 95dd33c6f1...
  • ccextractor --autoprogram --out=ttxt --latin1 01509e4d27...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla ab9cf8cfad...
  • ccextractor --autoprogram --out=srt --latin1 15feae9133...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --output-field 2 5d3a29f9f8...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --output-field 2 c41f73056a...
  • ccextractor --autoprogram --out=srt --latin1 --sentencecap c032183ef0...
  • ccextractor --autoprogram --out=bin --latin1 c032183ef0...
  • ccextractor --out=srt --latin1 --autoprogram 29e5ffd34b...
  • 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 --out=srt --latin1 f23a544ba8...
  • ccextractor --autoprogram --out=srt --latin1 --ucla d037c7509e...
  • ccextractor --autoprogram --out=srt --latin1 --ucla 7d3f25c32c...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 7f41299cc7...

NOTE: The following tests have been failing on the master branch as well as the PR:

Congratulations: Merging this PR would fix the following tests:

  • ccextractor --service 1 --out=ttxt da904de35d..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 132d7df7e9..., Last passed: Never

It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you).

Check the result page for more info.

Hi, I'm trying to check the CI results to understand why the tests aren't passing, but the link (sampleplatform.ccextractor.org) seems to be timing out for me. Could you please let me know if this is a known issue, or if there's another way I can view the test results?

@ccextractor-bot

Copy link
Copy Markdown
Collaborator
CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit 2feb09a...:
Report Name Tests Passed
Broken 9/13
CEA-708 2/14
DVB 2/7
DVD 3/3
DVR-MS 2/2
General 24/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 74/86
Teletext 20/21
WTV 12/13
XDS 31/34

Your PR breaks these cases:

  • ccextractor --out=srt --latin1 611b4a9235...
  • ccextractor --autoprogram --out=ttxt --latin1 1020459a86...
  • ccextractor --autoprogram --out=ttxt --latin1 132d7df7e9...
  • ccextractor --autoprogram --out=ttxt --latin1 99e5eaafdc...
  • ccextractor --autoprogram --out=ttxt --latin1 01509e4d27...
  • ccextractor --dru c83f765c66...
  • ccextractor --startat 4 --endat 7 c83f765c66...
  • 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 --out=srt --latin1 f23a544ba8...
  • ccextractor --autoprogram --out=srt --latin1 --ucla d037c7509e...
  • ccextractor --autoprogram --out=srt --latin1 --ucla 7d3f25c32c...
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 7f41299cc7...

NOTE: The following tests have been failing on the master branch as well as the PR:

Congratulations: Merging this PR would fix the following tests:

  • ccextractor --service 1 --out=ttxt da904de35d..., Last passed: Never
  • ccextractor --autoprogram --out=srt --latin1 --quant 0 85271be4d2..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla dab1c1bd65..., Last passed: Never
  • ccextractor --out=srt --latin1 --autoprogram 29e5ffd34b..., Last passed: Never
  • ccextractor --out=spupng c83f765c66..., Last passed: Never

It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you).

Check the result page for more info.

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.

[BUG] Rust panic in CEA-708 decoder at service_decoder.rs:264 on broadcast MPEG-2 transport streams

2 participants