From 9415b61953cc6659b214884c704c0746ef175d63 Mon Sep 17 00:00:00 2001 From: amr Date: Sun, 2 Nov 2025 07:04:51 +0000 Subject: [PATCH 1/3] Fix typo in systemd service Should probably also consider switching this to a "forking" service, and using the --daemon option --- systemd/chroma.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemd/chroma.service b/systemd/chroma.service index 54a09a5..369a898 100644 --- a/systemd/chroma.service +++ b/systemd/chroma.service @@ -21,4 +21,4 @@ ProtectHome=read-only ReadWritePaths=%h/.config/chroma [Install] -WantedBy=multi-useer.target +WantedBy=multi-user.target From ff2a2d977fe96ec19e2189822f9ffd52e2240bd1 Mon Sep 17 00:00:00 2001 From: amr Date: Sun, 2 Nov 2025 07:13:14 +0000 Subject: [PATCH 2/3] fix: this solves the warning during compilation This not only solves the warning/error brought up during compilation, it's also just a sort of belt'n'braces approach to make absolutely sure the timestamp length is correct and didn't get truncated or some other error. This was a new warning/error introduced back in gcc 7.1, and it's one of those "you *should* do it this way because it's technically the correct way" things that most developers roll their eyes at but, logically, they're technically correct. --- src/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core.c b/src/core.c index 63d904d..909caa1 100644 --- a/src/core.c +++ b/src/core.c @@ -364,17 +364,23 @@ void chroma_log(const char *level, const char *format, ...) { va_list args; char timestamp[32]; + int truncation_check = 0; struct timeval tv; struct tm *tm_info; gettimeofday(&tv, NULL); tm_info = localtime(&tv.tv_sec); - snprintf(timestamp, sizeof(timestamp), "%04d-%02d-%02d %02d:%02d:%02d.%03d", + truncation_check = snprintf(timestamp, sizeof(timestamp), "%04d-%02d-%02d %02d:%02d:%02d.%03d", tm_info->tm_year + 1900, tm_info->tm_mon + 1, tm_info->tm_mday, tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec, (int)(tv.tv_usec / 1000)); + if(truncation_check > 32 || truncation_check < 0) { + // Something went seriously wrong with the snprintf, this is a fairly serious error as + // the timestamp may be incomplete or corrupted, so print a warning + printf("Following timestamp may be incomplete, truncated or corrupted!\n"); + } printf("[%s] %s: ", timestamp, level); va_start(args, format); From 1f9050b69ec8435d340c92ea91db9a17d1bb7e2e Mon Sep 17 00:00:00 2001 From: amr Date: Sun, 2 Nov 2025 07:13:14 +0000 Subject: [PATCH 3/3] fix: this solves the warning during compilation This not only solves the warning/error brought up during compilation, it's also just a sort of belt'n'braces approach to make absolutely sure the timestamp length is correct and didn't get truncated or some other error. This was a new warning/error introduced back in gcc 7.1, and it's one of those "you *should* do it this way because it's technically the correct way" things that most developers roll their eyes at but, logically, they're technically correct. --- src/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core.c b/src/core.c index 63d904d..909caa1 100644 --- a/src/core.c +++ b/src/core.c @@ -364,17 +364,23 @@ void chroma_log(const char *level, const char *format, ...) { va_list args; char timestamp[32]; + int truncation_check = 0; struct timeval tv; struct tm *tm_info; gettimeofday(&tv, NULL); tm_info = localtime(&tv.tv_sec); - snprintf(timestamp, sizeof(timestamp), "%04d-%02d-%02d %02d:%02d:%02d.%03d", + truncation_check = snprintf(timestamp, sizeof(timestamp), "%04d-%02d-%02d %02d:%02d:%02d.%03d", tm_info->tm_year + 1900, tm_info->tm_mon + 1, tm_info->tm_mday, tm_info->tm_hour, tm_info->tm_min, tm_info->tm_sec, (int)(tv.tv_usec / 1000)); + if(truncation_check > 32 || truncation_check < 0) { + // Something went seriously wrong with the snprintf, this is a fairly serious error as + // the timestamp may be incomplete or corrupted, so print a warning + printf("Following timestamp may be incomplete, truncated or corrupted!\n"); + } printf("[%s] %s: ", timestamp, level); va_start(args, format);