Commit 99dbeb14 authored by Rob Swindell's avatar Rob Swindell 💬

Safe string handling with config-load error messages

We were just trusting that the error strings would be shorter than 256 (usually), but since we're including paths and strerror() results, we really have no control over the length of the error strings. So enforce some healthy boundaries. This could explain the crashes that Divarin of Mutiny is seeing with SCFG on WinXP or maybe it was the truncsp(strerror()) stuff that was just removed as well. We'll see...
parent 4e2567ad
Pipeline #1154 failed with stage
in 16 minutes and 23 seconds
......@@ -732,7 +732,7 @@ int main(int argc, char **argv)
fprintf(stderr,"!ERROR changing directory to: %s", scfg.ctrl_dir);
printf("\nLoading configuration files from %s\n",scfg.ctrl_dir);
if(!load_cfg(&scfg,NULL,TRUE,error)) {
if(!load_cfg(&scfg,NULL,TRUE,error, sizeof(error))) {
fprintf(stderr,"!ERROR loading configuration files: %s\n",error);
exit(1);
}
......
......@@ -113,7 +113,7 @@ int main(int argc, char **argv)
SAFECOPY(cfg.ctrl_dir, p);
backslash(cfg.ctrl_dir);
load_cfg(&cfg, NULL, TRUE, str);
load_cfg(&cfg, NULL, TRUE, str, sizeof(str));
chdir(cfg.ctrl_dir);
dirnum=libnum=-1;
......
......@@ -111,7 +111,7 @@ int main(int argc,char **argv)
cfg.size=sizeof(cfg);
SAFECOPY(cfg.ctrl_dir,p);
if(!load_cfg(&cfg,NULL,TRUE,str)) {
if(!load_cfg(&cfg,NULL,TRUE,str, sizeof(str))) {
fprintf(stderr,"!ERROR loading configuration files: %s\n",str);
return(1);
}
......
......@@ -153,7 +153,7 @@ int main(int argc, char **argv)
fprintf(stderr,"!ERROR changing directory to: %s", scfg.ctrl_dir);
printf("\nLoading configuration files from %s\n",scfg.ctrl_dir);
if(!load_cfg(&scfg,NULL,TRUE,error)) {
if(!load_cfg(&scfg,NULL,TRUE,error, sizeof(error))) {
fprintf(stderr,"!ERROR loading configuration files: %s\n",error);
exit(1);
}
......
......@@ -5175,7 +5175,7 @@ void DLLCALL ftp_server(void* arg)
lprintf(LOG_INFO,"Loading configuration files from %s", scfg.ctrl_dir);
scfg.size=sizeof(scfg);
SAFECOPY(error,UNKNOWN_LOAD_ERROR);
if(!load_cfg(&scfg, text, TRUE, error)) {
if(!load_cfg(&scfg, text, TRUE, error, sizeof(error))) {
lprintf(LOG_CRIT,"!ERROR %s",error);
lprintf(LOG_CRIT,"!Failed to load configuration files");
cleanup(1,__LINE__);
......
......@@ -1391,7 +1391,7 @@ int main(int argc, char **argv, char** env)
fprintf(errfp,"!ERROR changing directory to: %s\n", scfg.ctrl_dir);
fprintf(statfp,"\nLoading configuration files from %s\n",scfg.ctrl_dir);
if(!load_cfg(&scfg,text,TRUE,error)) {
if(!load_cfg(&scfg,text,TRUE,error, sizeof(error))) {
fprintf(errfp,"!ERROR loading configuration files: %s\n",error);
return(do_bail(1));
}
......
......@@ -40,7 +40,7 @@ char * readtext(long *line, FILE *stream, long dflt);
/****************************************************************************/
/* Initializes system and node configuration information and data variables */
/****************************************************************************/
BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[], BOOL prep, char* error)
BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[], BOOL prep, char* error, size_t maxerrlen)
{
int i;
#ifdef SBBS
......@@ -50,7 +50,7 @@ BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[], BOOL prep, char* error)
#endif
if(cfg->size!=sizeof(scfg_t)) {
sprintf(error,"cfg->size (%"PRIu32") != sizeof(scfg_t) (%" XP_PRIsize_t "d)"
safe_snprintf(error, maxerrlen,"cfg->size (%"PRIu32") != sizeof(scfg_t) (%" XP_PRIsize_t "d)"
,cfg->size,sizeof(scfg_t));
return(FALSE);
}
......@@ -64,7 +64,7 @@ BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[], BOOL prep, char* error)
cfg->node_num=1;
backslash(cfg->ctrl_dir);
if(read_main_cfg(cfg, error)==FALSE)
if(read_main_cfg(cfg, error, maxerrlen)==FALSE)
return(FALSE);
if(prep)
......@@ -73,17 +73,17 @@ BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[], BOOL prep, char* error)
SAFECOPY(cfg->node_dir,cfg->node_path[cfg->node_num-1]);
prep_dir(cfg->ctrl_dir, cfg->node_dir, sizeof(cfg->node_dir));
if(read_node_cfg(cfg, error)==FALSE)
if(read_node_cfg(cfg, error, maxerrlen)==FALSE)
return(FALSE);
if(read_msgs_cfg(cfg, error)==FALSE)
if(read_msgs_cfg(cfg, error, maxerrlen)==FALSE)
return(FALSE);
if(read_file_cfg(cfg, error)==FALSE)
if(read_file_cfg(cfg, error, maxerrlen)==FALSE)
return(FALSE);
if(read_xtrn_cfg(cfg, error)==FALSE)
if(read_xtrn_cfg(cfg, error, maxerrlen)==FALSE)
return(FALSE);
if(read_chat_cfg(cfg, error)==FALSE)
if(read_chat_cfg(cfg, error, maxerrlen)==FALSE)
return(FALSE);
if(read_attr_cfg(cfg, error)==FALSE)
if(read_attr_cfg(cfg, error, maxerrlen)==FALSE)
return(FALSE);
#ifdef SBBS
......@@ -94,7 +94,7 @@ BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[], BOOL prep, char* error)
SAFEPRINTF(str,"%stext.dat",cfg->ctrl_dir);
if((instream=fnopen(NULL,str,O_RDONLY))==NULL) {
sprintf(error,"%d opening %s",errno,str);
safe_snprintf(error, maxerrlen,"%d opening %s",errno,str);
return(FALSE);
}
for(i=0;i<TOTAL_TEXT;i++)
......@@ -105,7 +105,7 @@ BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[], BOOL prep, char* error)
fclose(instream);
if(i<TOTAL_TEXT) {
sprintf(error,"line %d: Less than TOTAL_TEXT (%u) strings defined in %s."
safe_snprintf(error, maxerrlen,"line %d: Less than TOTAL_TEXT (%u) strings defined in %s."
,i
,TOTAL_TEXT,str);
return(FALSE);
......@@ -353,7 +353,7 @@ int md(const char* inpath)
/****************************************************************************/
/* Reads in ATTR.CFG and initializes the associated variables */
/****************************************************************************/
BOOL read_attr_cfg(scfg_t* cfg, char* error)
BOOL read_attr_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
{
uint* clr;
char str[256];
......@@ -362,12 +362,12 @@ BOOL read_attr_cfg(scfg_t* cfg, char* error)
SAFEPRINTF(str,"%sattr.cfg",cfg->ctrl_dir);
if((instream=fnopen(NULL,str,O_RDONLY))==NULL) {
sprintf(error,"%d opening %s",errno,str);
safe_snprintf(error, maxerrlen,"%d opening %s",errno,str);
return(FALSE);
}
FREE_AND_NULL(cfg->color);
if((cfg->color=malloc(MIN_COLORS * sizeof(uint)))==NULL) {
sprintf(error,"Error allocating memory (%u bytes) for colors"
safe_snprintf(error, maxerrlen,"Error allocating memory (%u bytes) for colors"
,MIN_COLORS);
fclose(instream);
return(FALSE);
......
......@@ -29,7 +29,7 @@
extern "C" {
#endif
DLLEXPORT BOOL load_cfg(scfg_t* cfg, char* text[], BOOL prep, char* error);
DLLEXPORT BOOL load_cfg(scfg_t* cfg, char* text[], BOOL prep, char* error, size_t);
DLLEXPORT void free_cfg(scfg_t* cfg);
DLLEXPORT void free_text(char* text[]);
DLLEXPORT ushort sys_timezone(scfg_t* cfg);
......@@ -40,4 +40,4 @@ DLLEXPORT int md(const char *path);
#ifdef __cplusplus
}
#endif
#endif /* Don't add anything after this line */
\ No newline at end of file
#endif /* Don't add anything after this line */
......@@ -6145,7 +6145,7 @@ void DLLCALL mail_server(void* arg)
lprintf(LOG_INFO,"Loading configuration files from %s", scfg.ctrl_dir);
scfg.size=sizeof(scfg);
SAFECOPY(error,UNKNOWN_LOAD_ERROR);
if(!load_cfg(&scfg, text, TRUE, error)) {
if(!load_cfg(&scfg, text, TRUE, error, sizeof(error))) {
lprintf(LOG_CRIT,"!ERROR %s",error);
lprintf(LOG_CRIT,"!Failed to load configuration files");
cleanup(1);
......
......@@ -5131,7 +5131,7 @@ void DLLCALL bbs_thread(void* arg)
scfg.size=sizeof(scfg);
scfg.node_num=startup->first_node;
SAFECOPY(logstr,UNKNOWN_LOAD_ERROR);
if(!load_cfg(&scfg, text, TRUE, logstr)) {
if(!load_cfg(&scfg, text, TRUE, logstr, sizeof(logstr))) {
lprintf(LOG_CRIT,"!ERROR %s",logstr);
lprintf(LOG_CRIT,"!FAILED to load configuration files");
cleanup(1);
......@@ -5744,10 +5744,10 @@ NO_SSH:
SAFECOPY(cfg->ctrl_dir, startup->ctrl_dir);
lprintf(LOG_INFO,"Node %d Loading configuration files from %s", cfg->node_num, cfg->ctrl_dir);
SAFECOPY(logstr,UNKNOWN_LOAD_ERROR);
if(!load_cfg(cfg, node_text[i - 1], TRUE, logstr)) {
if(!load_cfg(cfg, node_text[i - 1], TRUE, logstr, sizeof(logstr))) {
lprintf(LOG_WARNING, "Node %d LOAD ERROR: %s, falling back to Node %d", cfg->node_num, logstr, first_node);
cfg->node_num = first_node;
if(!load_cfg(cfg, node_text[i - 1], TRUE, logstr)) {
if(!load_cfg(cfg, node_text[i - 1], TRUE, logstr, sizeof(logstr))) {
lprintf(LOG_CRIT,"!ERROR %s",logstr);
lprintf(LOG_CRIT,"!FAILED to load configuration files");
sbbs->bprintf("\r\nFAILED: %s", logstr);
......
......@@ -103,7 +103,7 @@ int main(int argc, char **argv)
fprintf(stderr,"!ERROR changing directory to: %s", scfg.ctrl_dir);
printf("\nLoading configuration files from %s\n",scfg.ctrl_dir);
if(!load_cfg(&scfg,NULL,TRUE,error)) {
if(!load_cfg(&scfg,NULL,TRUE,error, sizeof(error))) {
fprintf(stderr,"!ERROR loading configuration files: %s\n",error);
exit(1);
}
......
......@@ -244,7 +244,7 @@ int main(int argc, char **argv)
cfg.size=sizeof(cfg);
SAFECOPY(cfg.ctrl_dir, get_ctrl_dir(/* warn: */TRUE));
if(!load_cfg(&cfg, NULL, TRUE, str)) {
if(!load_cfg(&cfg, NULL, TRUE, str, sizeof(str))) {
printf("\7\n%s\n",str);
}
......
......@@ -1914,7 +1914,7 @@ int main(int argc, char** argv)
scfg.size=sizeof(scfg);
SAFECOPY(error,UNKNOWN_LOAD_ERROR);
lprintf(LOG_INFO,"Loading configuration files from %s", scfg.ctrl_dir);
if(!load_cfg(&scfg, NULL /* text.dat */, TRUE /* prep */, error)) {
if(!load_cfg(&scfg, NULL /* text.dat */, TRUE /* prep */, error, sizeof(error))) {
lprintf(LOG_ERR,"!ERROR Loading Configuration Files: %s", error);
return(-1);
}
......
......@@ -6259,7 +6259,7 @@ int main(int argc, char **argv)
printf("\nLoading configuration files from %s\n", scfg.ctrl_dir);
scfg.size=sizeof(scfg);
SAFECOPY(str,UNKNOWN_LOAD_ERROR);
if(!load_cfg(&scfg, NULL, true, str)) {
if(!load_cfg(&scfg, NULL, true, str, sizeof(str))) {
fprintf(stderr,"!ERROR %s\n",str);
fprintf(stderr,"!Failed to load configuration files\n");
bail(1);
......
......@@ -348,13 +348,13 @@ int main(int argc, char **argv)
}
printf("Reading main.cnf ... ");
if(!read_main_cfg(&cfg,error)) {
if(!read_main_cfg(&cfg,error,sizeof(error))) {
printf("ERROR: %s",error);
return EXIT_FAILURE;
}
printf("\n");
printf("Reading msgs.cnf ... ");
if(!read_msgs_cfg(&cfg,error)) {
if(!read_msgs_cfg(&cfg,error,sizeof(error))) {
printf("ERROR: %s",error);
return EXIT_FAILURE;
}
......@@ -434,7 +434,7 @@ int main(int argc, char **argv)
SAFEPRINTF(str,"%smain.cnf",cfg.ctrl_dir);
if(!fexist(str)) {
sprintf(errormsg,"Main configuration file (%s) missing!",str);
SAFEPRINTF(errormsg, "Main configuration file (%s) missing!",str);
uifc.msg(errormsg);
}
......@@ -475,8 +475,8 @@ int main(int argc, char **argv)
switch(uifc.list(WIN_ORG|WIN_MID|WIN_ESC|WIN_ACT,0,0,30,&main_dflt,0
,"Configure",mopt)) {
case 0:
if(!load_main_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_main_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg,"ERROR: %s",error);
uifc.msg(errormsg);
break;
}
......@@ -484,13 +484,13 @@ int main(int argc, char **argv)
free_main_cfg(&cfg);
break;
case 1:
if(!load_main_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_main_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg,"ERROR: %s",error);
uifc.msg(errormsg);
break;
}
if(!load_xtrn_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_xtrn_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg,"ERROR: %s",error);
uifc.msg(errormsg);
break;
}
......@@ -499,13 +499,13 @@ int main(int argc, char **argv)
free_main_cfg(&cfg);
break;
case 2:
if(!load_main_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_main_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg,"ERROR: %s",error);
uifc.msg(errormsg);
break;
}
if(!load_msgs_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_msgs_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg,"ERROR: %s",error);
uifc.msg(errormsg);
break;
}
......@@ -514,13 +514,13 @@ int main(int argc, char **argv)
free_main_cfg(&cfg);
break;
case 3:
if(!load_main_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_main_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg,"ERROR: %s",error);
uifc.msg(errormsg);
break;
}
if(!load_file_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_file_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg,"ERROR: %s",error);
uifc.msg(errormsg);
break;
}
......@@ -529,13 +529,13 @@ int main(int argc, char **argv)
free_main_cfg(&cfg);
break;
case 4:
if(!load_main_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_main_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg,"ERROR: %s",error);
uifc.msg(errormsg);
break;
}
if(!load_file_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_file_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg,"ERROR: %s",error);
uifc.msg(errormsg);
break;
}
......@@ -544,8 +544,8 @@ int main(int argc, char **argv)
free_main_cfg(&cfg);
break;
case 5:
if(!load_chat_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_chat_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg,"ERROR: %s",error);
uifc.msg(errormsg);
break;
}
......@@ -590,13 +590,13 @@ int main(int argc, char **argv)
free_chat_cfg(&cfg);
break;
case 6:
if(!load_main_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_main_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg, "ERROR: %s",error);
uifc.msg(errormsg);
break;
}
if(!load_msgs_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_msgs_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg, "ERROR: %s",error);
uifc.msg(errormsg);
break;
}
......@@ -605,13 +605,13 @@ int main(int argc, char **argv)
free_main_cfg(&cfg);
break;
case 7:
if(!load_main_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_main_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg, "ERROR: %s",error);
uifc.msg(errormsg);
break;
}
if(!load_msgs_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_msgs_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg, "ERROR: %s",error);
uifc.msg(errormsg);
break;
}
......@@ -620,8 +620,8 @@ int main(int argc, char **argv)
free_main_cfg(&cfg);
break;
case 8:
if(!load_main_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_main_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg, "ERROR: %s",error);
uifc.msg(errormsg);
break;
}
......@@ -629,13 +629,13 @@ int main(int argc, char **argv)
free_main_cfg(&cfg);
break;
case 9:
if(!load_main_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_main_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg, "ERROR: %s",error);
uifc.msg(errormsg);
break;
}
if(!load_xtrn_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_xtrn_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg, "ERROR: %s",error);
uifc.msg(errormsg);
break;
}
......@@ -644,13 +644,13 @@ int main(int argc, char **argv)
free_main_cfg(&cfg);
break;
case 10:
if(!load_main_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_main_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg, "ERROR: %s",error);
uifc.msg(errormsg);
break;
}
if(!load_file_cfg(&cfg,error)) {
sprintf(errormsg,"ERROR: %s",error);
if(!load_file_cfg(&cfg, error, sizeof(error))) {
SAFEPRINTF(errormsg, "ERROR: %s",error);
uifc.msg(errormsg);
break;
}
......@@ -677,50 +677,50 @@ int main(int argc, char **argv)
}
}
BOOL load_main_cfg(scfg_t* cfg, char *error)
BOOL load_main_cfg(scfg_t* cfg, char *error, size_t maxerrlen)
{
uifc.pop("Reading main.cnf ...");
BOOL result = read_main_cfg(cfg, error);
BOOL result = read_main_cfg(cfg, error, maxerrlen);
uifc.pop(NULL);
return result;
}
BOOL load_node_cfg(scfg_t* cfg, char *error)
BOOL load_node_cfg(scfg_t* cfg, char *error, size_t maxerrlen)
{
uifc.pop("Reading node.cnf ...");
BOOL result = read_node_cfg(cfg, error);
BOOL result = read_node_cfg(cfg, error, maxerrlen);
uifc.pop(NULL);
return result;
}
BOOL load_msgs_cfg(scfg_t* cfg, char *error)
BOOL load_msgs_cfg(scfg_t* cfg, char *error, size_t maxerrlen)
{
uifc.pop("Reading msgs.cnf ...");
BOOL result = read_msgs_cfg(cfg, error);
BOOL result = read_msgs_cfg(cfg, error, maxerrlen);
uifc.pop(NULL);
return result;
}
BOOL load_file_cfg(scfg_t* cfg, char *error)
BOOL load_file_cfg(scfg_t* cfg, char *error, size_t maxerrlen)
{
uifc.pop("Reading file.cnf ...");
BOOL result = read_file_cfg(cfg, error);
BOOL result = read_file_cfg(cfg, error, maxerrlen);
uifc.pop(NULL);
return result;
}
BOOL load_chat_cfg(scfg_t* cfg, char *error)
BOOL load_chat_cfg(scfg_t* cfg, char *error, size_t maxerrlen)
{
uifc.pop("Reading chat.cnf ...");
BOOL result = read_chat_cfg(cfg, error);
BOOL result = read_chat_cfg(cfg, error, maxerrlen);
uifc.pop(NULL);
return result;
}
BOOL load_xtrn_cfg(scfg_t* cfg, char *error)
BOOL load_xtrn_cfg(scfg_t* cfg, char *error, size_t maxerrlen)
{
uifc.pop("Reading xtrn.cnf ...");
BOOL result = read_xtrn_cfg(cfg, error);
BOOL result = read_xtrn_cfg(cfg, error, maxerrlen);
uifc.pop(NULL);
return result;
}
......@@ -2193,11 +2193,11 @@ void bail(int code)
getchar();
}
else if(forcesave) {
load_main_cfg(&cfg,error);
load_msgs_cfg(&cfg,error);
load_file_cfg(&cfg,error);
load_chat_cfg(&cfg,error);
load_xtrn_cfg(&cfg,error);
load_main_cfg(&cfg, error, sizeof(error));
load_msgs_cfg(&cfg, error, sizeof(error));
load_file_cfg(&cfg, error, sizeof(error));
load_chat_cfg(&cfg, error, sizeof(error));
load_xtrn_cfg(&cfg, error, sizeof(error));
cfg.new_install=new_install;
save_main_cfg(&cfg,backup_level);
save_msgs_cfg(&cfg,backup_level);
......
......@@ -153,12 +153,12 @@ void sort_subs(int grpnum);
void sort_dirs(int libnum);
unsigned subs_in_group(unsigned grpnum);
char random_code_char(void);
BOOL load_main_cfg(scfg_t*, char*);
BOOL load_node_cfg(scfg_t*, char*);
BOOL load_msgs_cfg(scfg_t*, char*);
BOOL load_file_cfg(scfg_t*, char*);
BOOL load_chat_cfg(scfg_t*, char*);
BOOL load_xtrn_cfg(scfg_t*, char*);
BOOL load_main_cfg(scfg_t*, char*, size_t);
BOOL load_node_cfg(scfg_t*, char*, size_t);
BOOL load_msgs_cfg(scfg_t*, char*, size_t);
BOOL load_file_cfg(scfg_t*, char*, size_t);
BOOL load_chat_cfg(scfg_t*, char*, size_t);
BOOL load_xtrn_cfg(scfg_t*, char*, size_t);
BOOL save_main_cfg(scfg_t*, int);
BOOL save_node_cfg(scfg_t*, int);
BOOL save_msgs_cfg(scfg_t*, int);
......
......@@ -100,7 +100,7 @@ void node_menu()
if(msk == MSK_INS) {
SAFECOPY(cfg.node_dir,cfg.node_path[cfg.sys_nodes-1]);
i=cfg.sys_nodes+1;
load_node_cfg(&cfg,error);
load_node_cfg(&cfg,error, sizeof(error));
if(i == 1) {
SAFEPRINTF(str,"../node%d/",i);
} else {
......@@ -135,7 +135,7 @@ void node_menu()
free_node_cfg(&cfg);
i&=MSK_OFF;
SAFECOPY(cfg.node_dir,cfg.node_path[i]);
load_node_cfg(&cfg,error);
load_node_cfg(&cfg,error, sizeof(error));
savnode=1;
continue;
}
......@@ -155,7 +155,7 @@ void node_menu()
SAFECOPY(cfg.node_dir,cfg.node_path[i]);
prep_dir(cfg.ctrl_dir, cfg.node_dir, sizeof(cfg.node_dir));
load_node_cfg(&cfg,error);
load_node_cfg(&cfg,error, sizeof(error));
if (cfg.node_num != i + 1) { /* Node number isn't right? */
cfg.node_num = i + 1; /* so fix it */
save_node_cfg(&cfg, backup_level); /* and write it back */
......
/* Synchronet configuration library routine prototypes */
/* $Id: scfglib.h,v 1.25 2020/05/14 07:50:00 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
......@@ -15,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
......@@ -51,16 +37,16 @@ extern "C" {
#endif
char* get_alloc(long *offset, char *outstr, int maxlen, FILE *instream);
BOOL allocerr(FILE*, char* error, long offset, char *fname, uint size);
BOOL allocerr(FILE*, char* error, size_t maxerrlen, long offset, const char *fname, size_t size);
char* readline(long *offset, char *str, int maxlen, FILE *stream);
BOOL read_node_cfg(scfg_t* cfg, char* error);
BOOL read_main_cfg(scfg_t* cfg, char* error);
BOOL read_xtrn_cfg(scfg_t* cfg, char* error);
BOOL read_file_cfg(scfg_t* cfg, char* error);
BOOL read_msgs_cfg(scfg_t* cfg, char* error);
BOOL read_chat_cfg(scfg_t* cfg, char* error);
BOOL read_attr_cfg(scfg_t* cfg, char* error);
BOOL read_node_cfg(scfg_t* cfg, char* error, size_t);
BOOL read_main_cfg(scfg_t* cfg, char* error, size_t);
BOOL read_xtrn_cfg(scfg_t* cfg, char* error, size_t);
BOOL read_file_cfg(scfg_t* cfg, char* error, size_t);
BOOL read_msgs_cfg(scfg_t* cfg, char* error, size_t);
BOOL read_chat_cfg(scfg_t* cfg, char* error, size_t);
BOOL read_attr_cfg(scfg_t* cfg, char* error, size_t);
char* prep_path(char* path);
void make_data_dirs(scfg_t* cfg);
......
This diff is collapsed.
This diff is collapsed.
......@@ -1805,7 +1805,7 @@ void DLLCALL services_thread(void* arg)
lprintf(LOG_INFO,"Loading configuration files from %s", scfg.ctrl_dir);
scfg.size<