-
Notifications
You must be signed in to change notification settings - Fork 512
Fix buffer truncation warnings in EPG time strings #1910
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
base: master
Are you sure you want to change the base?
Fix buffer truncation warnings in EPG time strings #1910
Conversation
Increased buffer size from 21 to 32 bytes for start_time_string and end_time_string to prevent potential truncation with large year values in snprintf formatting. Fixes compiler warnings in ts_tables_epg.c lines 130, 150, 181
cfsmp3
left a comment
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.
Thank you for working on this! However, after testing locally, the warnings are still present:
Master: 3 warnings
This PR: Still 3 warnings
The compiler calculates that snprintf output could be up to 73 bytes, but the buffer is only 32 bytes. The issue is that the format string allows unbounded year values.
To properly fix this, you could either:
- Increase buffer size to 80 bytes (to safely accommodate all theoretical values)
- Validate/bound the year values before formatting
- If these warnings are false positives (years will never be that large in practice), consider suppressing them with a pragma
Could you update the fix to fully eliminate the warnings?
Per @cfsmp3's feedback, 32 bytes was insufficient. Compiler calculates snprintf could need up to 73 bytes in worst case. Using 80 bytes ensures all theoretical values are safely accommodated.
@cfsmp3 Thank you for testing and the detailed feedback! You're absolutely right. I've updated the buffer size to 80 bytes to fully accommodate the compiler's calculated maximum of 73 bytes. This should completely eliminate all three warnings. The updated commit increases both Ready for another review when you have time. Thanks again for the guidance! |
CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit fd15528...:
Congratulations: Merging this PR would fix the following tests:
All tests passed completely. Check the result page for more info. |
CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit fd15528...:
Congratulations: Merging this PR would fix the following tests:
All tests passed completely. Check the result page for more info. |
Summary
Fixed buffer size for EPG time string buffers to prevent truncation warnings.
Changes
start_time_stringandend_time_stringbuffer size from 21 to 32 bytes ints_functions.hRationale
The compiler warned that
snprintfformatting ints_tables_epg.ccould truncate with large year values (e.g., 5+ digit years). While unlikely in practice, this fix ensures safety and eliminates three compiler warnings at lines 130, 150, and 181.Testing
ts_tables_epg.cWarnings Fixed