Make temporary directory safely when ~/.w3m is unwritable

This commit is contained in:
Tatsuya Kinoshita
2018-01-21 01:29:10 +09:00
parent b592dac63b
commit 18dcbadf27
6 changed files with 16 additions and 2 deletions

5
rc.c
View File

@@ -1330,6 +1330,11 @@ init_rc(void)
((tmp_dir = getenv("TMP")) == NULL || *tmp_dir == '\0') &&
((tmp_dir = getenv("TEMP")) == NULL || *tmp_dir == '\0'))
tmp_dir = "/tmp";
#ifdef HAVE_MKDTEMP
tmp_dir = mkdtemp(Strnew_m_charp(tmp_dir, "/w3m-XXXXXX", NULL)->ptr);
if (tmp_dir == NULL)
tmp_dir = rc_dir;
#endif
create_option_search_table();
goto open_rc;
}