files: when the requested operating directory cannot be set, fail
Specifying an operating directory should either lead to a successfull confinement, or nano should fail to start. (Also: save the terminal settings as soon as possible, so that an early die() will not restore uninitialized values.) This fixes the first part of https://savannah.gnu.org/bugs/?47798 properly.
This commit is contained in:
12
src/files.c
12
src/files.c
@@ -1563,15 +1563,9 @@ void init_operating_dir(void)
|
||||
|
||||
full_operating_dir = get_full_path(operating_dir);
|
||||
|
||||
/* If get_full_path() failed or the operating directory is
|
||||
* inaccessible, unset operating_dir. */
|
||||
if (full_operating_dir == NULL || chdir(full_operating_dir) == -1) {
|
||||
statusline(ALERT, _("Not a valid directory: %s"), operating_dir);
|
||||
free(full_operating_dir);
|
||||
full_operating_dir = NULL;
|
||||
free(operating_dir);
|
||||
operating_dir = NULL;
|
||||
}
|
||||
/* If the operating directory is inaccessible, fail. */
|
||||
if (full_operating_dir == NULL || chdir(full_operating_dir) == -1)
|
||||
die("Invalid operating directory\n");
|
||||
}
|
||||
|
||||
/* Check to see if we're inside the operating directory. Return FALSE
|
||||
|
||||
Reference in New Issue
Block a user