-
Notifications
You must be signed in to change notification settings - Fork 539
fix(mcc_encoder): prevent buffer overruns and add OOM checks #1804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
- Add NULL checks after malloc calls for compressed_data_buffer and buff_ptr - Replace sprintf with snprintf for all string formatting operations - Replace strcat with bounds-checked direct character assignment - Replace vsprintf with vsnprintf in debug_log function - Replace sprintf loop in random_chars with direct character lookup table - Increase buffer sizes for date_str (50->64), time_str (30->32), tcr_str (25->32) - Initialize tcr_str in default case to prevent uninitialized use - Add lib_ccx.h include for fatal() function declaration Functions modified: - mcc_encode_cc_data: OOM check + sprintf -> snprintf + strcat -> direct assignment - generate_mcc_header: sprintf -> snprintf for uuid_str, date_str, time_str, tcr_str - add_boilerplate: OOM check for buff_ptr - random_chars: sprintf -> direct character lookup (more efficient) - debug_log: vsprintf -> vsnprintf + safer strlen check 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
082a0c1 to
37fed5e
Compare
Collaborator
CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit 77e1dff...:
Congratulations: Merging this PR would fix the following tests:
All tests passing on the master branch were passed completely. Check the result page for more info. |
Collaborator
CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit 1510396...:
Congratulations: Merging this PR would fix the following tests:
All tests passing on the master branch were passed completely. Check the result page for more info. |
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.
Summary
This PR fixes multiple buffer overrun vulnerabilities and missing out-of-memory (OOM) checks in the MCC (MacCaption) encoder in
src/lib_ccx/ccx_encoders_mcc.c.Issues Found and Fixed
1. Missing OOM Checks (2 instances)
mcc_encode_cc_datacompressed_data_bufferadd_boilerplatebuff_ptrFix: Added
fatal(EXIT_NOT_ENOUGH_MEMORY, ...)checks after each allocation.2. Unsafe
sprintfCalls (12 instances)All
sprintfcalls into fixed-size buffers were replaced withsnprintf:mcc_encode_cc_datacompressed_data_buffergenerate_mcc_headeruuid_strgenerate_mcc_headerdate_strgenerate_mcc_headertime_strgenerate_mcc_headertcr_str(7 locations)3. Unsafe
strcatCallBefore:
After:
4. Unsafe
vsprintfindebug_logBefore:
After:
5. Inefficient
sprintfLoop inrandom_charsBefore:
After:
6. Uninitialized Buffer in Default Case
Added
tcr_str[0] = '\0';in the default case of the framerate switch to prevent using uninitialized data.Code Changes Summary
malloc()without NULL checksprintf()callssnprintf()callsstrcat()callsvsprintf()callsvsnprintf()callsSecurity Impact
These fixes prevent:
MCC output is used for professional broadcast captioning, making reliability important.
Test Plan
🤖 Generated with Claude Code