Skip to content
Snippets Groups Projects
Commit 3a3e4dbd authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Resolve relative menu/../* to absolute path before checking for file existence

On *nix, fexist("../mods/text/menu/../filename") would fail unless the
mods/text/menu sub-directory existed. It works on Windows fine however.

This resolves issue #918, reported by Keyop - thank you!
parent b8e2bbc1
No related branches found
No related tags found
No related merge requests found
Pipeline #8918 passed
...@@ -358,6 +358,8 @@ bool sbbs_t::menu_exists(const char *code, const char* ext, char* path) ...@@ -358,6 +358,8 @@ bool sbbs_t::menu_exists(const char *code, const char* ext, char* path)
char modpath[MAX_PATH + 1]; char modpath[MAX_PATH + 1];
snprintf(modprefix, sizeof modprefix, "%stext/menu/%s%s", cfg.mods_dir, subdir, code); snprintf(modprefix, sizeof modprefix, "%stext/menu/%s%s", cfg.mods_dir, subdir, code);
snprintf(modpath, sizeof modpath, "%s.%s", modprefix, ext); snprintf(modpath, sizeof modpath, "%s.%s", modprefix, ext);
FULLPATH(path, modpath, MAX_PATH);
SAFECOPY(modpath, path);
if (fexist(modpath)) { if (fexist(modpath)) {
FULLPATH(path, modprefix, MAX_PATH); FULLPATH(path, modprefix, MAX_PATH);
SAFECOPY(prefix, path); SAFECOPY(prefix, path);
...@@ -408,6 +410,8 @@ bool sbbs_t::random_menu(const char *name, int mode, JSObject* obj) ...@@ -408,6 +410,8 @@ bool sbbs_t::random_menu(const char *name, int mode, JSObject* obj)
if (cfg.mods_dir[0] != '\0') { if (cfg.mods_dir[0] != '\0') {
char modpath[MAX_PATH + 1]; char modpath[MAX_PATH + 1];
SAFEPRINTF2(modpath, "%stext/menu/%s", cfg.mods_dir, name); SAFEPRINTF2(modpath, "%stext/menu/%s", cfg.mods_dir, name);
FULLPATH(path, modpath, sizeof path);
SAFECOPY(modpath, path);
if (fexist(modpath)) if (fexist(modpath))
SAFECOPY(path, modpath); SAFECOPY(path, modpath);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment