mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-03 21:23:48 +00:00
Integer overflow in Transport Stream buffer allocation may lead to heap buffer overflow (ts_functions.c) #878
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: Transport Stream (TS) handling
File: src/lib_ccx/ts_functions.c
Function: copy_payload_to_capbuf
Problem
The function copy_payload_to_capbuf grows a capture buffer using:
However, there was no check for integer overflow before this addition.
If a very large payload->length is combined with capbuflen, the sum can wrap around, resulting in a very small allocation passed to realloc.
This can cause a heap buffer overflow when data is copied into the buffer, potentially crashing the program or corrupting memory.
Proposed Fix
Changed newcapbuflen to int64_t to handle large sums safely.
Added an explicit overflow guard:
Used size_t cast safely in the realloc call.
Ensured program logs an error and returns safely if allocation fails.
Impact