From 624be8785d02b264067f4ed5ee47f5d9afdfaece Mon Sep 17 00:00:00 2001 From: gustav Date: Mon, 28 Oct 2024 12:56:02 +0100 Subject: [PATCH 1/3] Fix file length calculation dlt_logstorage_log_file_name assumed the suffix always is .dlt which is not be the case if gzip compression is enabled. Changed to assume .dlt.gz when smax is calculated as it prevents buffer overflow if filenames are long and gzip is enabled. --- src/offlinelogstorage/dlt_offline_logstorage_behavior.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c index fb9c95f2..2fe81ac0 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c +++ b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c @@ -99,7 +99,9 @@ void dlt_logstorage_log_file_name(char *log_file_name, index_width = 0; } - const char * suffix = ".dlt"; + const char *suffix = + ".dlt.gz"; // Unknown here if gzip is used but we assume so as it leads + // to shorter avaialble space const int smax = DLT_MOUNT_PATH_MAX - strlen(suffix) - 1; int spos = 0; log_file_name[spos] = '\0'; From d1a7906e7057750eee50cb3ab2d7a5fc4f8bc9dc Mon Sep 17 00:00:00 2001 From: gustav Date: Mon, 28 Oct 2024 13:07:57 +0100 Subject: [PATCH 2/3] typo --- src/offlinelogstorage/dlt_offline_logstorage_behavior.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c index 2fe81ac0..5d8cb2ca 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c +++ b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c @@ -101,7 +101,7 @@ void dlt_logstorage_log_file_name(char *log_file_name, const char *suffix = ".dlt.gz"; // Unknown here if gzip is used but we assume so as it leads - // to shorter avaialble space + // to shorter available space const int smax = DLT_MOUNT_PATH_MAX - strlen(suffix) - 1; int spos = 0; log_file_name[spos] = '\0'; From 1e9d14167e032de2ff9a9d946509f8923c1f1b3b Mon Sep 17 00:00:00 2001 From: gustav Date: Thu, 21 Nov 2024 07:31:52 +0100 Subject: [PATCH 3/3] Make file suffix dependent on gzip compression --- src/offlinelogstorage/dlt_offline_logstorage_behavior.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c index 5d8cb2ca..4f4b7661 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c +++ b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c @@ -100,8 +100,8 @@ void dlt_logstorage_log_file_name(char *log_file_name, } const char *suffix = - ".dlt.gz"; // Unknown here if gzip is used but we assume so as it leads - // to shorter available space + filter_config->gzip_compression == DLT_LOGSTORAGE_GZIP_ON ? ".dlt.gz" + : ".dlt"; const int smax = DLT_MOUNT_PATH_MAX - strlen(suffix) - 1; int spos = 0; log_file_name[spos] = '\0';