From 6eec2e470300f2642ff0496b3ea3a31d26033886 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on ChromeOS)" <rob@synchro.net>
Date: Fri, 3 Feb 2023 19:50:54 -0800
Subject: [PATCH] Insure that the max (uploaded) filename limit is in the range
 8-65535 characters

Upgrading fromm v3.19 can result in a setting of filename_maxlen=0 in file.ini, so let's
put a special check in place to insure this can't happen (thus preventing any file
uploads). I chose '8' as a kind of arbitrary minimum maximum value (MS-DOS filenames
maxed out at 12 characters), but at least 0 won't be possibly any longer.

As reported on DOVE-Net by Codefenix and confirmed by xbit.
---
 src/sbbs3/scfglib2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/sbbs3/scfglib2.c b/src/sbbs3/scfglib2.c
index 7e621eb6a7..ee98031898 100644
--- a/src/sbbs3/scfglib2.c
+++ b/src/sbbs3/scfglib2.c
@@ -70,7 +70,7 @@ BOOL read_file_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
 	cfg->leech_pct = iniGetShortInt(ini, ROOT_SECTION, "leech_pct", 0);
 	cfg->leech_sec = iniGetShortInt(ini, ROOT_SECTION, "leech_sec", 0);
 	cfg->file_misc = iniGetInt32(ini, ROOT_SECTION, "settings", 0);
-	cfg->filename_maxlen = iniGetShortInt(ini, ROOT_SECTION, "filename_maxlen", SMB_FILEIDX_NAMELEN);
+	cfg->filename_maxlen = iniGetIntInRange(ini, ROOT_SECTION, "filename_maxlen", 8, SMB_FILEIDX_NAMELEN, UINT16_MAX);
 
 	named_str_list_t** sections = iniParseSections(ini);
 
-- 
GitLab