Skip to content

[FIX] Fix EPG crash on empty extended event text - #2389

Merged
cfsmp3 merged 1 commit into
masterfrom
fix/xmltv-segfault
Oct 18, 2026
Merged

cfsmp3 merged 1 commit into
masterfrom
fix/xmltv-segfault

Conversation

@cfsmp3

@cfsmp3 cfsmp3 commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

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:

ccextractor 4b117b4d66e81f393a67a07358d143beeb4f384dc9d1c640761f7eeca9f707e7.ts --xmltv 1 (a DVB recording from our sample set) segfaults (exit 139). The 75 EIT packets (PID 0x12) from its first 2 MB, 14,100 bytes, reproduce it on their own; under ASan: heap-buffer-overflow, READ of size 4294967295 in memcpy from EPG_decode_extended_event_descriptor (ts_tables_epg.c:993).


EPG_decode_extended_event_descriptor() strips a leading character-table byte from a continuation descriptor (descriptor_number > 0) when the first text byte is below 0x20. When text_length is 0, that byte isn't text but whatever follows the descriptor, and text_length-- wraps the uint32_t to 0xFFFFFFFF, so the following memcpy reads 4 GB. An empty text field is legal — this broadcaster puts all extended event content in the item fields (the crashing call: descriptor 3, text_length 0, next byte 0x09). This only strips the byte when there is text to strip.

Verified:

  • The sample and the 14 KB reproducer: segfault / ASan heap-buffer-overflow before; with this change both complete, ASan clean, and the XMLTV file is written (656 programmes).
  • 29 local TS samples, default and --xmltv 1: output and exit codes identical to master, except the crashing sample.

EPG_decode_extended_event_descriptor() strips a leading character-table
byte from a continuation descriptor (descriptor_number > 0) when the
first text byte is below 0x20. When text_length is 0 that byte is not
text but whatever follows the descriptor, and the decrement wraps the
uint32_t length to 0xFFFFFFFF, so the following memcpy reads 4 GB and
--xmltv segfaults. An empty text field is legal: some broadcasters put
all extended event content in the item fields.

Only strip the byte when there is text to strip.
@cfsmp3
cfsmp3 merged commit d0410a6 into master Oct 18, 2026
46 of 48 checks passed
@cfsmp3
cfsmp3 deleted the fix/xmltv-segfault branch October 18, 2026 04:00
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.

1 participant