From: David Griffith Date: Sun, 7 May 2023 17:59:38 +0000 (-0700) Subject: Restricted curses no-prompt file access to current dir or restricted path. X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=a0917931e40257fc3faae9669f972f6dad30f562;p=liskon_frotz.git Restricted curses no-prompt file access to current dir or restricted path. --- diff --git a/src/curses/ux_input.c b/src/curses/ux_input.c index b38a613..34bd022 100644 --- a/src/curses/ux_input.c +++ b/src/curses/ux_input.c @@ -1093,8 +1093,17 @@ char *os_read_file_name (const char *default_name, int flag) } /* Use the default name if nothing was typed */ - if (file_name[0] == 0) - strncpy (file_name, default_name, FILENAME_MAX); + if (file_name[0] == 0) { + /* If FILE_NO_PROMPT, restrict to currect directory. */ + /* If FILE_NO_PROMPT and using restricted path, then */ + /* nothing more needs to be done to restrict the */ + /* file access there. */ + if (flag == FILE_NO_PROMPT && f_setup.restricted_path == NULL) { + tempname = basename((char *)default_name); + strncpy(file_name, tempname, FILENAME_MAX); + } else + strncpy (file_name, default_name, FILENAME_MAX); + } /* If we're restricted to one directory, strip any leading path left * over from a previous call to os_read_file_name(), then prepend