-
Notifications
You must be signed in to change notification settings - Fork 515
fix DTVCC: Heap Buffer Overflow & Out-of-Bounds Read #1968
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
cfsmp3
merged 7 commits into
CCExtractor:master
from
THE-Amrit-mahto-05:fix/dtvcc-critical-bugs
Jan 3, 2026
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5dc8292
Fix out-of-bounds read in H.264 SEI parsing
82109e6
Fix DTVCC structural type confusion and OOB writes (#1961)
3e1424c
Fix TS/ES: Integer overflow, stack overflow, heap over-read
cc7a43b
[FIX] Teletext decoder: fix OOB read/write and loop overflow (#1965)
028ce9d
[FIX] DTVCC: Heap Overflow & OOB Read
1255b31
[FIX] Remove dead safety checks per reviewer feedback
44eb665
chore: apply clang-format fixes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -582,9 +582,23 @@ void dtvcc_window_copy_to_screen(dtvcc_service_decoder *decoder, dtvcc_window *w | |
| top = top < 0 ? 0 : top; | ||
| left = left < 0 ? 0 : left; | ||
|
|
||
| // Invariant check: window should never be defined with values exceeding MAX constants | ||
| if (window->row_count > CCX_DTVCC_MAX_ROWS || window->col_count > CCX_DTVCC_MAX_COLUMNS) | ||
| { | ||
| ccx_common_logging.debug_ftn(CCX_DMT_708, "[CEA-708] dtvcc_window_copy_to_screen: W-%d HAS INVALID DIMENSIONS %dx%d\n", | ||
| window->number, window->row_count, window->col_count); | ||
| return; | ||
| } | ||
|
|
||
| int copyrows = top + window->row_count >= CCX_DTVCC_SCREENGRID_ROWS ? CCX_DTVCC_SCREENGRID_ROWS - top : window->row_count; | ||
| int copycols = left + window->col_count >= CCX_DTVCC_SCREENGRID_COLUMNS ? CCX_DTVCC_SCREENGRID_COLUMNS - left : window->col_count; | ||
|
|
||
| // Use window dimensions as secondary safety guard | ||
| if (copyrows > window->row_count) | ||
| copyrows = window->row_count; | ||
| if (copycols > window->col_count) | ||
| copycols = window->col_count; | ||
|
|
||
| ccx_common_logging.debug_ftn( | ||
| CCX_DMT_708, "[CEA-708] %d*%d will be copied to the TV.\n", copyrows, copycols); | ||
|
|
||
|
|
@@ -795,6 +809,14 @@ void dtvcc_process_character(dtvcc_service_decoder *decoder, dtvcc_symbol symbol | |
| if (cw == -1 || !window->is_defined) // Writing to a non existing window, skipping | ||
| return; | ||
|
|
||
| if (window->pen_row < 0 || window->pen_row >= CCX_DTVCC_MAX_ROWS || | ||
| window->pen_column < 0 || window->pen_column >= CCX_DTVCC_MAX_COLUMNS) | ||
| { | ||
| ccx_common_logging.debug_ftn(CCX_DMT_708, "[CEA-708] dtvcc_process_character: pen out of bounds (%d:%d)\n", | ||
| window->pen_row, window->pen_column); | ||
| return; | ||
| } | ||
|
|
||
| window->is_empty = 0; | ||
| window->rows[window->pen_row][window->pen_column] = symbol; | ||
| window->pen_attribs[window->pen_row][window->pen_column] = window->pen_attribs_pattern; // "Painting" char by pen - attribs | ||
|
|
@@ -998,6 +1020,14 @@ void dtvcc_handle_DFx_DefineWindow(dtvcc_service_decoder *decoder, int window_id | |
| int row_count = (data[4] & 0xf) + 1; // according to CEA-708-D | ||
| int anchor_point = data[4] >> 4; | ||
| int col_count = (data[5] & 0x3f) + 1; // according to CEA-708-D | ||
|
|
||
| if (row_count > CCX_DTVCC_MAX_ROWS || col_count > CCX_DTVCC_MAX_COLUMNS) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this even possible, considering that we are doing a mask with 0xf? |
||
| { | ||
| ccx_common_logging.log_ftn("[CEA-708] Invalid window size %dx%d (max %dx%d), rejecting window definition\n", | ||
| row_count, col_count, CCX_DTVCC_MAX_ROWS, CCX_DTVCC_MAX_COLUMNS); | ||
| return; | ||
| } | ||
|
|
||
| int pen_style = data[6] & 0x7; | ||
| int win_style = (data[6] >> 3) & 0x7; | ||
|
|
||
|
|
@@ -1341,6 +1371,14 @@ void dtvcc_handle_SPL_SetPenLocation(dtvcc_service_decoder *decoder, unsigned ch | |
| } | ||
|
|
||
| dtvcc_window *window = &decoder->windows[decoder->current_window]; | ||
| if (row >= window->row_count || col >= window->col_count) | ||
| { | ||
| ccx_common_logging.log_ftn("[CEA-708] dtvcc_handle_SPL_SetPenLocation: " | ||
| "Invalid pen location %d:%d for window size %dx%d, rejecting command\n", | ||
| row, col, window->row_count, window->col_count); | ||
| return; | ||
| } | ||
|
|
||
| window->pen_row = row; | ||
| window->pen_column = col; | ||
| } | ||
|
|
@@ -1754,6 +1792,12 @@ void dtvcc_process_current_packet(dtvcc_ctx *dtvcc, int len) | |
|
|
||
| if (service_number == 7) // There is an extended header | ||
| { | ||
| if (pos + 1 >= dtvcc->current_packet + len) | ||
| { | ||
| ccx_common_logging.debug_ftn(CCX_DMT_708, "[CEA-708] dtvcc_process_current_packet: " | ||
| "Truncated extended header, stopping.\n"); | ||
| break; | ||
| } | ||
| pos++; | ||
| service_number = (pos[0] & 0x3F); // 6 more significant bits | ||
| // printf ("Extended header: Service number: [%d]\n",service_number); | ||
|
|
||
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessary. sei_message never returns NULLs.