mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-15 13:35:30 +00:00
[PR #2008] fix(matroska): abort parsing on invalid EBML ID to prevent infinite loop #2811
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/CCExtractor/ccextractor/pull/2008
State: closed
Merged: No
[FIX] matroska: Abort parsing on invalid element ID (0xFFFFFFFF) to prevent infinite loops
In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Summary
This PR fixes a critical regression where the legacy C Matroska parser (
matroska.c) enters an infinite loop when encountering invalid EBML IDs (specifically0xFFFFFFFF) or EOF conditions inside segment/cluster loops.The Issue
In
parse_segment,parse_segment_cluster, and related functions, the loop structure was:skip_bytes.0xFFFFFFFF(EOF/Error),skip_bytesskips 0 bytes.The Fix
Added an explicit check for
code == 0xFFFFFFFFin the parsing loops. The parser now detects this "Invalid ID" state and aborts the loop gracefully with a specific error message.Verification
Tested against corrupted/truncated MKV samples that previously caused hangs.
Before: Infinite loop, process hangs.

After: Logs "Invalid EBML ID... Aborting segment parsing" and exits successfully.

