From 1012c49e3ad45299ca1fb6712118a83dfaffacf2 Mon Sep 17 00:00:00 2001
From: Rob Swindell <rob@synchro.net>
Date: Sun, 1 Jan 2023 21:24:39 -0800
Subject: [PATCH] Timed event month-days (mdays) is 32-bit, not 16

Fix issue #470 reported via IRC: timed event "mdays" values were read and written as 16-bit values, meaning any setting for days > 15 would do weird things.
---
 src/sbbs3/scfglib2.c | 2 +-
 src/sbbs3/scfgsave.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/sbbs3/scfglib2.c b/src/sbbs3/scfglib2.c
index 0a5831d356..8e6fe9e488 100644
--- a/src/sbbs3/scfglib2.c
+++ b/src/sbbs3/scfglib2.c
@@ -550,7 +550,7 @@ BOOL read_xtrn_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
 		cfg->event[i]->misc = iniGetInt32(section, NULL, "settings", 0);
 		SAFECOPY(cfg->event[i]->dir, iniGetString(section, NULL, "startup_dir", "", value));
 		cfg->event[i]->freq = iniGetShortInt(section, NULL, "freq", 0);
-		cfg->event[i]->mdays = iniGetShortInt(section, NULL, "mdays", 0);
+		cfg->event[i]->mdays = iniGetUInt32(section, NULL, "mdays", 0);
 		cfg->event[i]->months = iniGetShortInt(section, NULL, "months", 0);
 		cfg->event[i]->errlevel = (uint8_t)iniGetShortInt(section, NULL, "errlevel", LOG_ERR);
 
diff --git a/src/sbbs3/scfgsave.c b/src/sbbs3/scfgsave.c
index a7cc2b79db..8e878bc3a2 100644
--- a/src/sbbs3/scfgsave.c
+++ b/src/sbbs3/scfgsave.c
@@ -954,7 +954,7 @@ BOOL write_xtrn_cfg(scfg_t* cfg, int backup_level)
 		iniSetHexInt(&section, name, "settings", cfg->event[i]->misc, NULL);
 		iniSetString(&section, name, "startup_dir", cfg->event[i]->dir, NULL);
 		iniSetShortInt(&section, name, "freq", cfg->event[i]->freq, NULL);
-		iniSetShortInt(&section, name, "mdays", cfg->event[i]->mdays, NULL);
+		iniSetHexInt(&section, name, "mdays", cfg->event[i]->mdays, NULL);
 		iniSetShortInt(&section, name, "months", cfg->event[i]->months, NULL);
 		iniSetShortInt(&section, name, "errlevel", cfg->event[i]->errlevel, NULL);
 		strListMerge(&ini, section);
-- 
GitLab