- files.c:do_browser() - Fix goto directory operating dir check and tilde expansion (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1409 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
858d9d90cb
commit
f80a59c7cc
|
@ -35,6 +35,8 @@ CVS Code -
|
||||||
do_browser()
|
do_browser()
|
||||||
- Fix incorrect path check for check_operating_dir()
|
- Fix incorrect path check for check_operating_dir()
|
||||||
(David Benbennick).
|
(David Benbennick).
|
||||||
|
- Fix goto directory operating dir check and tilde expansion
|
||||||
|
(David Benbennick).
|
||||||
open_file()
|
open_file()
|
||||||
- Fix FD leak with file load error (David Benbennick).
|
- Fix FD leak with file load error (David Benbennick).
|
||||||
save_history()
|
save_history()
|
||||||
|
|
39
files.c
39
files.c
|
@ -2515,6 +2515,8 @@ char *do_browser(const char *inpath)
|
||||||
/* Loop invariant: Microsoft sucks. */
|
/* Loop invariant: Microsoft sucks. */
|
||||||
do {
|
do {
|
||||||
DIR *test_dir;
|
DIR *test_dir;
|
||||||
|
char *new_path;
|
||||||
|
/* Used by the Go To Directory prompt. */
|
||||||
|
|
||||||
blank_statusbar_refresh();
|
blank_statusbar_refresh();
|
||||||
|
|
||||||
|
@ -2694,37 +2696,36 @@ char *do_browser(const char *inpath)
|
||||||
bottombars(browser_list);
|
bottombars(browser_list);
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
|
||||||
if (operating_dir != NULL) {
|
|
||||||
if (check_operating_dir(answer, 0)) {
|
|
||||||
statusbar(_("Can't go outside of %s in restricted mode"), operating_dir);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (j < 0) {
|
if (j < 0) {
|
||||||
statusbar(_("Goto Cancelled"));
|
statusbar(_("Goto Cancelled"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (answer[0] != '/') {
|
new_path = real_dir_from_tilde(answer);
|
||||||
char *saveanswer = mallocstrcpy(NULL, answer);
|
|
||||||
|
|
||||||
answer = nrealloc(answer, strlen(path) + strlen(saveanswer) + 2);
|
if (new_path[0] != '/') {
|
||||||
sprintf(answer, "%s/%s", path, saveanswer);
|
new_path = charealloc(new_path, strlen(path) + strlen(answer) + 2);
|
||||||
free(saveanswer);
|
sprintf(new_path, "%s/%s", path, answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((test_dir = opendir(answer)) == NULL) {
|
#ifndef DISABLE_OPERATINGDIR
|
||||||
/* We can't open this dir for some reason. Complain */
|
if (check_operating_dir(new_path, FALSE)) {
|
||||||
statusbar(_("Can't open \"%s\": %s"), answer, strerror(errno));
|
statusbar(_("Can't go outside of %s in restricted mode"), operating_dir);
|
||||||
|
free(new_path);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!readable_dir(new_path)) {
|
||||||
|
/* We can't open this dir for some reason. Complain */
|
||||||
|
statusbar(_("Can't open \"%s\": %s"), answer, strerror(errno));
|
||||||
|
free(new_path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
closedir(test_dir);
|
|
||||||
|
|
||||||
/* Start over again with the new path value */
|
/* Start over again with the new path value */
|
||||||
path = mallocstrcpy(path, answer);
|
free(path);
|
||||||
|
path = new_path;
|
||||||
return do_browser(path);
|
return do_browser(path);
|
||||||
|
|
||||||
/* Stuff we want to abort the browser */
|
/* Stuff we want to abort the browser */
|
||||||
|
|
1
nano.h
1
nano.h
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
/* Define charalloc as a macro rather than duplicating code */
|
/* Define charalloc as a macro rather than duplicating code */
|
||||||
#define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char))
|
#define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char))
|
||||||
|
#define charealloc(ptr, howmuch) (char *)nrealloc(ptr, (howmuch) * sizeof(char))
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
/* For the backup file copy ... */
|
/* For the backup file copy ... */
|
||||||
|
|
Loading…
Reference in New Issue