From 5ac67261b4acb12756f4b5cbb400d7e00d64aa82 Mon Sep 17 00:00:00 2001 From: pranayr710 Date: Tue, 24 Nov 2026 19:28:06 +0530 Subject: [PATCH] [FIX] GXF: don't let an oversized mpeg packet overflow the demuxer buffer parse_mpeg_packet() does buffered_read(data->buffer + data->len, len) where len is mpeg_pic_size, a 24-bit value taken straight from the GXF media packet header. data->buffer is a fixed BUFSIZE (2 MB) allocation and nothing checks len against it, so a media packet that declares an mpeg_pic_size larger than the buffer writes past its end. Reject (skip) the packet when it would not fit instead of reading it in. Found with AddressSanitizer: heap-buffer-overflow WRITE via buffered_read, ../src/lib_ccx/ccx_gxf.c:930 in parse_mpeg_packet --- src/lib_ccx/ccx_gxf.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lib_ccx/ccx_gxf.c b/src/lib_ccx/ccx_gxf.c index a123ef149..5b5d8aed7 100644 --- a/src/lib_ccx/ccx_gxf.c +++ b/src/lib_ccx/ccx_gxf.c @@ -927,6 +927,19 @@ static int parse_mpeg_packet(struct ccx_demuxer *demux, int len, struct demuxer_ int ret = CCX_OK; int result = 0; + /* len is the packet's mpeg_pic_size, taken straight from the file (a + 24-bit value). data->buffer is a fixed BUFSIZE allocation, so make + sure the read fits before it writes past the end of the buffer. */ + if (len < 0 || (size_t)data->len + (size_t)len > (size_t)BUFSIZE) + { + log("GXF: mpeg packet size %d does not fit the demuxer buffer; skipping\n", len); + result = buffered_skip(demux, len); + demux->past += result; + if (result != len) + ret = CCX_EOF; + return ret; + } + result = buffered_read(demux, data->buffer + data->len, len); data->len += len; demux->past += result;