From 7866f10684be4118c0cf4a29c2f45e8cdf1b4196 Mon Sep 17 00:00:00 2001 From: "Rob Swindell (on Debian Linux)" <rob@synchro.net> Date: Fri, 8 Dec 2023 23:01:30 -0800 Subject: [PATCH] Move the startup directory checking to the "native" block of *nix build of sbbs_t::external() The startup directory for DOS doors might not be a valid Unix (case-sensitive) path, so let's just do that check in the native block here. Also, removed a bunch of redundant startup_dir ==/!= NULL checks. It can't be NULL here. --- src/sbbs3/xtrn.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sbbs3/xtrn.cpp b/src/sbbs3/xtrn.cpp index a86df3a177..5114d11cd8 100644 --- a/src/sbbs3/xtrn.cpp +++ b/src/sbbs3/xtrn.cpp @@ -1109,11 +1109,6 @@ int sbbs_t::external(const char* cmdline, int mode, const char* startup_dir) xtrn_mode = mode; lprintf(LOG_DEBUG, "Executing external: %s", cmdline); - if(startup_dir!=NULL && startup_dir[0] && !isdir(startup_dir)) { - errormsg(WHERE, ERR_CHK, startup_dir, 0); - return -1; - } - if(startup_dir==NULL) startup_dir=nulstr; @@ -1129,13 +1124,18 @@ int sbbs_t::external(const char* cmdline, int mode, const char* startup_dir) SAFECOPY(fname,getfname(str)); snprintf(fullpath, sizeof fullpath, "%s%s",startup_dir,fname); - if(startup_dir!=NULL && cmdline[0]!='/' && cmdline[0]!='.' && fexist(fullpath)) + if(cmdline[0]!='/' && cmdline[0]!='.' && fexist(fullpath)) snprintf(fullcmdline, sizeof fullcmdline, "%s%s",startup_dir,cmdline); else SAFECOPY(fullcmdline,cmdline); if(native) { // Native (not MS-DOS) external + if(startup_dir[0] && !isdir(startup_dir)) { + errormsg(WHERE, ERR_CHK, startup_dir, 0); + return -1; + } + // Current environment passed to child process snprintf(dszlog, sizeof dszlog, "%sPROTOCOL.LOG",cfg.node_dir); setenv("DSZLOG",dszlog,1); /* Makes the DSZ LOG active */ @@ -1182,7 +1182,7 @@ int sbbs_t::external(const char* cmdline, int mode, const char* startup_dir) errormsg(WHERE,ERR_CREATE,str,0); return(-1); } - if(startup_dir!=NULL && startup_dir[0]) + if(startup_dir[0]) fprintf(doscmdrc,"assign C: %s\n",startup_dir); else fprintf(doscmdrc,"assign C: .\n"); @@ -1361,7 +1361,7 @@ int sbbs_t::external(const char* cmdline, int mode, const char* startup_dir) fprintf(dosemubatfp,"SET PCBDIR=\\\r\n"); char gamedir[MAX_PATH+1]{}; - if(startup_dir!=NULL && startup_dir[0]) { + if(startup_dir[0]) { SAFECOPY(str, startup_dir); *lastchar(str) = 0; SAFECOPY(gamedir, getfname(str)); @@ -1641,7 +1641,7 @@ int sbbs_t::external(const char* cmdline, int mode, const char* startup_dir) chdir(cfg.node_dir); else #endif - if(startup_dir!=NULL && startup_dir[0]) + if(startup_dir[0]) if(chdir(startup_dir)!=0) { errormsg(WHERE,ERR_CHDIR,startup_dir,0); return(-1); -- GitLab