aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-08-11 12:01:39 +0200
committerMarkus Uhlin <markus@nifty-networks.net>2024-08-11 12:01:39 +0200
commit3062df29cfb3b452594e7c09d8be7e578ebbac8e (patch)
treefdda26adfafdabb761a7ac97f973cd2a69eb18ed /FICS
parent29d8b69e834be5dd035787c26b1738c3dcb3a9d8 (diff)
Improved fix_time()
Diffstat (limited to 'FICS')
-rw-r--r--FICS/utils.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/FICS/utils.c b/FICS/utils.c
index b69a5ea..d7abeca 100644
--- a/FICS/utils.c
+++ b/FICS/utils.c
@@ -700,13 +700,18 @@ strtime(struct tm * stm)
PUBLIC char *
fix_time(char *old_time)
{
- char date[5];
- char day[5];
+ char date[5] = { '\0' };
+ char day[5] = { '\0' };
char i;
- char month[5];
+ char month[5] = { '\0' };
static char new_time[20];
- sscanf(old_time, "%s %s %s", day, month, date);
+ _Static_assert(4 < ARRAY_SIZE(day), "Array too small");
+ _Static_assert(4 < ARRAY_SIZE(month), "Array too small");
+ _Static_assert(4 < ARRAY_SIZE(date), "Array too small");
+
+ if (sscanf(old_time, "%4s %4s %4s", day, month, date) != 3)
+ warnx("%s: sscanf: too few items (%s)", __func__, old_time);
if (date[2] != ',') {
i = date[0];