From 532f443e5ca0f92169174d498e84ba791415de20 Mon Sep 17 00:00:00 2001 From: Harshdhall01 Date: Fri, 26 Dec 2025 21:04:07 +0530 Subject: [PATCH 1/3] Fix buffer truncation warnings in EPG time strings 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 --- src/lib_ccx/ts_functions.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib_ccx/ts_functions.h b/src/lib_ccx/ts_functions.h index 80508fe84..fe2baf11f 100644 --- a/src/lib_ccx/ts_functions.h +++ b/src/lib_ccx/ts_functions.h @@ -50,8 +50,8 @@ struct EPG_rating struct EPG_event { uint32_t id; - char start_time_string[21]; //"YYYYMMDDHHMMSS +0000" = 20 chars - char end_time_string[21]; + char start_time_string[32]; // Increased to prevent truncation warnings with large years + char end_time_string[32]; uint8_t running_status; uint8_t free_ca_mode; char ISO_639_language_code[4]; From 03d181056869b8da9b3f63bc8cb5d89680316ad3 Mon Sep 17 00:00:00 2001 From: Harshdhall01 Date: Mon, 29 Dec 2025 20:43:08 +0530 Subject: [PATCH 2/3] Increase buffer size to 80 bytes to fully eliminate 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. --- src/lib_ccx/ts_functions.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib_ccx/ts_functions.h b/src/lib_ccx/ts_functions.h index fe2baf11f..ff8979622 100644 --- a/src/lib_ccx/ts_functions.h +++ b/src/lib_ccx/ts_functions.h @@ -50,8 +50,8 @@ struct EPG_rating struct EPG_event { uint32_t id; - char start_time_string[32]; // Increased to prevent truncation warnings with large years - char end_time_string[32]; + char start_time_string[80]; // Increased to prevent truncation warnings with large years + char end_time_string[80]; uint8_t running_status; uint8_t free_ca_mode; char ISO_639_language_code[4]; From 9270313d16106623508dba5badb0b32d7dc68ca7 Mon Sep 17 00:00:00 2001 From: Harshdhall01 Date: Tue, 30 Dec 2025 15:21:28 +0530 Subject: [PATCH 3/3] Add size parameter to EPG_ATSC_calc_time to eliminate hardcoded buffer size --- src/lib_ccx/ts_tables_epg.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib_ccx/ts_tables_epg.c b/src/lib_ccx/ts_tables_epg.c index 381a77edc..fd2efca98 100644 --- a/src/lib_ccx/ts_tables_epg.c +++ b/src/lib_ccx/ts_tables_epg.c @@ -116,7 +116,7 @@ void EPG_ATSC_decode_ETT_text(uint8_t *offset, uint32_t length, struct EPG_event } // Fills given string with given (event.*_time_string) ATSC time converted to XMLTV style time string -void EPG_ATSC_calc_time(char *output, uint32_t time) +void EPG_ATSC_calc_time(char *output, size_t output_size, uint32_t time) { struct tm timeinfo; timeinfo.tm_year = 1980 - 1900; @@ -127,7 +127,7 @@ void EPG_ATSC_calc_time(char *output, uint32_t time) timeinfo.tm_hour = 0; timeinfo.tm_isdst = -1; mktime(&timeinfo); - snprintf(output, 21, "%02d%02d%02d%02d%02d%02d +0000", timeinfo.tm_year + 1900, timeinfo.tm_mon + 1, timeinfo.tm_mday, timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec); + snprintf(output, output_size, "%02d%02d%02d%02d%02d%02d +0000", timeinfo.tm_year + 1900, timeinfo.tm_mon + 1, timeinfo.tm_mday, timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec); } // Fills event.start_time_string in XMLTV format with passed DVB time @@ -1115,9 +1115,9 @@ void EPG_ATSC_decode_EIT(struct lib_ccx_ctx *ctx, uint8_t *payload_start, uint32 event.service_id = source_id; start_time = (offset[2] << 24) | (offset[3] << 16) | (offset[4] << 8) | (offset[5] << 0); - EPG_ATSC_calc_time(event.start_time_string, start_time); + EPG_ATSC_calc_time(event.start_time_string, sizeof(event.start_time_string), start_time); length_in_seconds = (((offset[6] & 0x0F) << 16) | (offset[7] << 8) | (offset[8] << 0)); - EPG_ATSC_calc_time(event.end_time_string, start_time + length_in_seconds); + EPG_ATSC_calc_time(event.end_time_string, sizeof(event.end_time_string), start_time + length_in_seconds); title_length = offset[9]; // XXX cant decode data more then size of payload