mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-14 21:23:42 +00:00
Integer overflow in EIA-608 screen buffer allocation may lead to heap buffer overflow #873
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?
Originally created by @THE-Amrit-mahto-05 on GitHub (Jan 1, 2026).
Description
Component: EIA-608 decoder
File: src/lib_ccx/ccx_decoders_608.c
Function: write_cc_buffer, write_cc_line
The Problem
The EIA-608 decoder dynamically grows its screen buffer using realloc based on the number of subtitle screens processed:
However, there is no check for integer overflow. If a malformed or crafted input triggers a very high number of screen updates, this calculation can wrap around, resulting in a very small buffer allocation. Subsequent writes then cause a heap buffer overflow, potentially crashing the program or corrupting memory.
The Proposed Fix
Added an overflow guard:
Calculated allocation size explicitly using size_t new_size
Ensured safe handling of realloc failure (log and return without corrupting memory)
This prevents the heap overflow caused by integer overflow while keeping behavior unchanged for normal input.
Impact
Processing malformed EIA-608 subtitle data will no longer result in: