aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2026-03-23 19:39:59 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2026-03-23 19:39:59 +0100
commitdcea2298797ef57de7bba7c950f81ea6edfbe1f1 (patch)
tree43edcf201f4be4439f6c1d7b31a225c51218ae24
parente3c38326f9a0763bed965f044d7ed0feab574b4d (diff)
Handle zero return from strftime()
-rw-r--r--FICS/gamedb.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/FICS/gamedb.c b/FICS/gamedb.c
index 0691c12..17e4a39 100644
--- a/FICS/gamedb.c
+++ b/FICS/gamedb.c
@@ -581,6 +581,7 @@ movesToString(int g, int pgn)
const char *serv_name = settings_get("server_name");
int i, col;
int wr, br;
+ size_t ret;
struct tm v_tm = {0};
time_t curTime;
@@ -602,11 +603,14 @@ movesToString(int g, int pgn)
errno = 0;
if (localtime_r(&curTime, &v_tm) != NULL) {
- strftime(tmp, sizeof(tmp),
+ ret = strftime(tmp, sizeof(tmp),
"[Date \"%Y.%m.%d\"]\n"
"[Time \"%H:%M:%S\"]\n",
&v_tm);
- mstrlcat(gameString, tmp, sizeof gameString);
+ if (ret != 0)
+ mstrlcat(gameString, tmp, sizeof gameString);
+ else
+ warnx("%s: strftime() returned 0", __func__);
} else
warn("%s: localtime_r()", __func__);
@@ -686,8 +690,12 @@ movesToString(int g, int pgn)
errno = 0;
if (localtime_r(&curTime, &v_tm) != NULL) {
- strftime(tmp, sizeof tmp, "%Y.%m.%d %H:%M:%S", &v_tm);
- mstrlcat(gameString, tmp, sizeof gameString);
+ ret = strftime(tmp, sizeof tmp, "%Y.%m.%d %H:%M:%S",
+ &v_tm);
+ if (ret != 0)
+ mstrlcat(gameString, tmp, sizeof gameString);
+ else
+ warnx("%s: strftime() returned 0", __func__);
} else
warn("%s: localtime_r()", __func__);