Repository navigation
[FIX] GXF: don't let an oversized mpeg packet overflow the demuxer buffer - #2501
Open
pranayr710 wants to merge 1 commit into
Open
pranayr710 wants to merge 1 commit into
pranayr710 wants to merge 1 commit into
Conversation
…ffer 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
Collaborator
CCExtractor CI platform finished running the test files on linux. 171/238 tests matched the approved output:
67 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.
Compared with the tip of master — test 10124, commit 034fdbc:
Compared with the commit this branch was cut from: the same run as the tip of master (test 10124), so the comparison above already covers it. No test changes behaviour relative to the tip of master: every failure above fails there too, byte for byte. The approved output for those tests is out of date, which is a baseline to review rather than a regression in this branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2500.
Problem
parse_mpeg_packet()readsmpeg_pic_sizebytes into the fixedBUFSIZE(≈2 MB) demuxer buffer without any bounds check:lenismpeg_pic_size, a 24-bit value taken straight from the GXF media packet header (so up to ~16 MB). A media packet that declares an oversizedmpeg_pic_sizeoverflowsdata->buffer. The ancillary branch inparse_media()already guards its size (len < ad_track->packet_size); the MPEG2 branch had no equivalent.Fix
Skip the packet when it would not fit, instead of reading it in:
Verification (AddressSanitizer)
heap-buffer-overflowwrite viabuffered_read,parse_mpeg_packetatccx_gxf.c:930mpeg packet size 2101368 does not fit the demuxer buffer; skipping, processing completesReproduction generator (Python)
This is a separate defect from #2499/#2498 (the CDP
cc_countread); both are "a GXF length field used without bounding it against the destination buffer".Analysis and the ASan reproduction were done with AI assistance; the fix and this description were reviewed by me.