[PR #1800] [MERGED] fix(708_output): replace sprintf with snprintf for buffer safety #2539

Closed
opened 2026-01-29 17:22:40 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/1800
Author: @cfsmp3
Created: 12/12/2025
Status: Merged
Merged: 12/13/2025
Merged by: @cfsmp3

Base: masterHead: fix/708-output-buffer-safety


📝 Commits (2)

  • fb49d94 fix(708_output): replace sprintf with snprintf for buffer safety
  • 155f56e style: fix clang-format issues in macro definitions

📊 Changes

2 files changed (+171 additions, -65 deletions)

View changed files

📝 src/lib_ccx/ccx_decoders_708_output.c (+170 -64)
📝 src/lib_ccx/ccx_decoders_708_output.h (+1 -1)

📄 Description

Summary

  • Replace all ~40 sprintf calls with snprintf to prevent potential buffer overflows in CEA-708 decoder output functions
  • Add buffer size tracking and bounds checking throughout the file
  • Update add_needed_scc_labels function signature to accept buffer size parameter

Changes

Function Change
dtvcc_change_pen_colors Add bounds checking for font color HTML tags
dtvcc_change_pen_attribs Add bounds checking for italic/underline HTML tags
dtvcc_write_srt Track buffer length with snprintf for SRT timestamps
dtvcc_write_transcript Add bounds checking for CC/mode labels
dtvcc_write_sami_header Use snprintf macro for all SAMI header tags
dtvcc_write_sami_footer Use snprintf with length check
dtvcc_write_sami Add bounds checking for sync tags
dtvcc_write_scc_header Use snprintf for SCC header
add_needed_scc_labels Add buffer size parameter for safe writes
dtvcc_write_scc Use snprintf macro for all SCC formatting
dtvcc_writer_init Use snprintf for filename suffix

Test plan

  • Build succeeds without errors
  • Verify CEA-708 SRT output format is unchanged
  • Verify CEA-708 SAMI output format is unchanged
  • Verify CEA-708 SCC output format is unchanged
  • Verify CEA-708 transcript output format is unchanged

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/CCExtractor/ccextractor/pull/1800 **Author:** [@cfsmp3](https://github.com/cfsmp3) **Created:** 12/12/2025 **Status:** ✅ Merged **Merged:** 12/13/2025 **Merged by:** [@cfsmp3](https://github.com/cfsmp3) **Base:** `master` ← **Head:** `fix/708-output-buffer-safety` --- ### 📝 Commits (2) - [`fb49d94`](https://github.com/CCExtractor/ccextractor/commit/fb49d9460d4de54c4d7cfc966edb6ccaa6079cbe) fix(708_output): replace sprintf with snprintf for buffer safety - [`155f56e`](https://github.com/CCExtractor/ccextractor/commit/155f56ede7dc2f2c30f502b6444fa2d2453ebfe9) style: fix clang-format issues in macro definitions ### 📊 Changes **2 files changed** (+171 additions, -65 deletions) <details> <summary>View changed files</summary> 📝 `src/lib_ccx/ccx_decoders_708_output.c` (+170 -64) 📝 `src/lib_ccx/ccx_decoders_708_output.h` (+1 -1) </details> ### 📄 Description ## Summary - Replace all ~40 `sprintf` calls with `snprintf` to prevent potential buffer overflows in CEA-708 decoder output functions - Add buffer size tracking and bounds checking throughout the file - Update `add_needed_scc_labels` function signature to accept buffer size parameter ## Changes | Function | Change | |----------|--------| | `dtvcc_change_pen_colors` | Add bounds checking for font color HTML tags | | `dtvcc_change_pen_attribs` | Add bounds checking for italic/underline HTML tags | | `dtvcc_write_srt` | Track buffer length with snprintf for SRT timestamps | | `dtvcc_write_transcript` | Add bounds checking for CC/mode labels | | `dtvcc_write_sami_header` | Use snprintf macro for all SAMI header tags | | `dtvcc_write_sami_footer` | Use snprintf with length check | | `dtvcc_write_sami` | Add bounds checking for sync tags | | `dtvcc_write_scc_header` | Use snprintf for SCC header | | `add_needed_scc_labels` | Add buffer size parameter for safe writes | | `dtvcc_write_scc` | Use snprintf macro for all SCC formatting | | `dtvcc_writer_init` | Use snprintf for filename suffix | ## Test plan - [x] Build succeeds without errors - [ ] Verify CEA-708 SRT output format is unchanged - [ ] Verify CEA-708 SAMI output format is unchanged - [ ] Verify CEA-708 SCC output format is unchanged - [ ] Verify CEA-708 transcript output format is unchanged 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 17:22:40 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2539