[PR #1981] fix(epg): Silence snprintf buffer truncation warnings #2784

Open
opened 2026-01-29 17:23:52 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/CCExtractor/ccextractor/pull/1981

State: closed
Merged: Yes


Summary

Extends EPG time string buffers from 21 to 74 bytes to silence compiler warnings about potential buffer truncation.

Problem

Every build showed warnings like:

ts_tables_epg.c:128:35: warning: '%02d' directive output may be truncated writing between 2 and 11 bytes into a region of size between 10 and 19 [-Wformat-truncation=]
ts_tables_epg.c:128:9: note: 'snprintf' output between 19 and 73 bytes into a destination of size 21

Solution

The actual output is always 20 chars (YYYYMMDDHHMMSS +0000) plus null terminator, but the compiler warns because %02d with int arguments could theoretically produce larger output (e.g., if year were somehow negative or very large).

Extended buffers to 74 bytes to match the compiler's calculated maximum, eliminating the warning while maintaining correct functionality.

Changes

  • ts_functions.h: start_time_string[21]start_time_string[74]
  • ts_functions.h: end_time_string[21]end_time_string[74]
  • ts_tables_epg.c: snprintf(output, 21, ...)snprintf(output, 74, ...)

Test Plan

  • Build completes with no warnings
  • No functional changes - output format remains the same

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/CCExtractor/ccextractor/pull/1981 **State:** closed **Merged:** Yes --- ## Summary Extends EPG time string buffers from 21 to 74 bytes to silence compiler warnings about potential buffer truncation. ## Problem Every build showed warnings like: ``` ts_tables_epg.c:128:35: warning: '%02d' directive output may be truncated writing between 2 and 11 bytes into a region of size between 10 and 19 [-Wformat-truncation=] ts_tables_epg.c:128:9: note: 'snprintf' output between 19 and 73 bytes into a destination of size 21 ``` ## Solution The actual output is always 20 chars (`YYYYMMDDHHMMSS +0000`) plus null terminator, but the compiler warns because `%02d` with `int` arguments could theoretically produce larger output (e.g., if year were somehow negative or very large). Extended buffers to 74 bytes to match the compiler's calculated maximum, eliminating the warning while maintaining correct functionality. ## Changes - `ts_functions.h`: `start_time_string[21]` → `start_time_string[74]` - `ts_functions.h`: `end_time_string[21]` → `end_time_string[74]` - `ts_tables_epg.c`: `snprintf(output, 21, ...)` → `snprintf(output, 74, ...)` ## Test Plan - [x] Build completes with no warnings - [x] No functional changes - output format remains the same 🤖 Generated with [Claude Code](https://claude.com/claude-code)
claunia added the pull-request label 2026-01-29 17:23:52 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2784