From 93a8c94862d8c7614646041343b8d2af6a1a0b20 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Sun, 29 Sep 2024 20:45:20 -0400
Subject: [PATCH] Fix bug generating SAUCE date introduced by commit dcf8c35f9b

Using snprintf() prevents the last character of the date from
being put into the string.
---
 src/syncterm/term.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/syncterm/term.c b/src/syncterm/term.c
index ae7c6c38b8..3539e7b26f 100644
--- a/src/syncterm/term.c
+++ b/src/syncterm/term.c
@@ -2273,7 +2273,10 @@ capture_control(struct bbslist *bbs)
 							if ((tm = localtime(&t)) != NULL) { // The null-terminator
                                                                                             // overwrites the first
                                                                                             // byte of filesize
-								snprintf(sauce.date, sizeof(sauce.date), "%04u%02u%02u",
+								// We can't use snprintf() here because snprintf()
+								// Is guaranteed to terminate, so the last digit
+								// would always be truncated.
+								sprintf(sauce.date, sizeof(sauce.date), "%04u%02u%02u",
 								    1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday);
 							}
 							sauce.filesize = LE_INT32(ftell(fp)); // LE
-- 
GitLab